<template>
  <div class="Service overflowY" v-loading="loading">
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> 
      <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
    </object>
    <!--<div class="PageTitle"><i class="iconfont icon-jia"></i>服务洽谈</div>-->
    <div class="PageContent" :style="{paddingBottom:fixedFlag?'150px':0}">
      <el-form :model="ruleForm" :inline="true" ref="ruleForm" autocomplete="off" label-width="120px"
               class="demo-ruleForm"
               @submit.native.prevent>
        <div class="PageItem">
          <el-row :gutter="0" class="paddingleft2">
            <el-form-item label="业务编码:" prop="name">
              <el-input v-model="businessCodeTitle" ref="homebusinessCode" autocomplete="off"
                        @keyup.enter.native="searchData(businessCodeTitle)"
                        :maxlength="20" placeholder="请输入业务编码"
                        style="width:230px">
                <el-button
                  type="primary"
                  slot="append"
                  icon="el-icon-circle-close"
                  @click="businessCodeTitle=''"
                ></el-button>
                <el-button type="primary" slot="append" icon="el-icon-search" v-if="btnlimits.btnBusinessCodeScanning"
                           @click="searchData(businessCode)"></el-button>
              </el-input>
            </el-form-item>
            <el-button type="primary" v-if="btnlimits.btnBusinessSearch" @click="businessSearchShow()">业务查询</el-button>

            <el-form-item label="业务编码:">
              <span class="titlecont">{{ ruleForm.funeralDead.businessCode }}</span>
            </el-form-item>
            <el-form-item label="逝者姓名:">
              <span class="titlecont">{{ ruleForm.funeralDead.deadName }}</span>
            </el-form-item>
            <!-- <el-form-item label="减免区域:">
              <span class="titlecont">{{ ruleForm.funeralDead.benefitDistrict }}</span>
            </el-form-item> -->
            <el-form-item label="减免类型:">
              <span class="titlecont">{{ ruleForm.funeralDead.exemptionType }}</span>
            </el-form-item>
            <el-form-item label="家属姓名:">
              <span class="titlecont">{{ ruleForm.familyMember.memberName }}</span>
            </el-form-item>

            <i class="el-icon-arrow-down more" v-if="!moreFlag" @click="moreFlag=!moreFlag">&nbsp;展开</i>

            <i class="el-icon-arrow-up more" v-if="moreFlag" @click="moreFlag=!moreFlag">&nbsp;收起</i>
          </el-row>
        </div>
        <transition name="fade">
          <div class="PageItem" v-if="moreFlag">
            <div style="display: inline-block;">
              <el-row class="PageInfo"><i class="info-bar"></i>逝者基本信息</el-row>
              <el-row :gutter="0" class="paddingleft2">
                <el-form-item label="业务编码:">
                  <span class="cont">{{ ruleForm.funeralDead.businessCode }}</span>
                </el-form-item>
                <el-form-item label="逝者姓名:">
                  <span class="cont">{{ ruleForm.funeralDead.deadName }}</span>
                </el-form-item>
                <el-form-item label="证件号码:">
                  <span class="cont">{{ ruleForm.funeralDead.certificateNo }}</span>
                </el-form-item>
                <el-form-item label="性别:">
                  <span class="cont">{{ ruleForm.funeralDead.deadGender }}</span>
                </el-form-item>
              </el-row>
              <el-row :gutter="0" class="paddingleft2">
                <el-form-item label="减免区域:">
                  <span class="cont">{{ ruleForm.funeralDead.benefitDistrict }}</span>
                </el-form-item>
                <el-form-item label="减免类型:">
                  <span class="cont">{{ ruleForm.funeralDead.exemptionType }}</span>
                </el-form-item>
                <el-form-item label="接尸地点:">
                  <span class="cont">{{ ruleForm.funeralDead.transportPlace }}</span>
                </el-form-item>
                <el-form-item label="死亡原因:">
                  <span class="cont">{{ ruleForm.funeralDead.deathCause }}</span>
                </el-form-item>
              </el-row>
              <el-row class="PageInfo"><i class="info-bar"></i>家属基本信息</el-row>
              <el-row :gutter="0" class="paddingleft2">
                <el-form-item label="家属姓名:">
                  <span class="cont">{{ ruleForm.familyMember.memberName }}</span>
                </el-form-item>
                <el-form-item label="证件号码:">
                  <span class="cont">{{ ruleForm.familyMember.certificateNo }}</span>
                </el-form-item>
                <el-form-item label="与逝者关系:">
                  <span class="cont">{{ ruleForm.familyMember.memberRelation }}</span>
                </el-form-item>
                <el-form-item label="联系方式:">
                  <span class="cont">{{ ruleForm.familyMember.mobilePhone }}</span>
                </el-form-item>
              </el-row>
              <el-row class="PageInfo"><i class="info-bar"></i>承办人基本信息</el-row>
              <el-row :gutter="0" class="paddingleft2">
                <el-form-item label="承办人姓名:">
                  <span class="cont">{{ ruleForm.familyAgent.agentName }}</span>
                </el-form-item>
                <el-form-item label="证件号码:">
                  <span class="cont">{{ ruleForm.familyAgent.certificateNo }}</span>
                </el-form-item>
                <el-form-item label="与逝者关系:">
                  <span class="cont">{{ ruleForm.familyAgent.agentRelation }}</span>
                </el-form-item>
                <el-form-item label="联系方式:">
                  <span class="cont">{{ ruleForm.familyAgent.mobilePhone }}</span>
                </el-form-item>
              </el-row>

            </div>
          </div>
        </transition>
        <el-row></el-row>
        <div class="PageItem" v-if="btnlimits.transportTaskDialog" hidden="hidden">
          <el-row class="PageInfo">
            <el-col :span="21"><i class="info-bar"></i>接运信息</el-col>
            <el-col :span="3" style="text-align: right">
              <el-button type="success" icon="el-icon-plus" @click="AddCarry()" v-if="btnlimits.btnAddTransportTask">
                追加接运任务
              </el-button>
            </el-col>
          </el-row>
          <div class="border1" v-if="ruleForm.transportTasks.length>0" v-for="(item,index) in ruleForm.transportTasks">
            <el-row :gutter="5">
              <el-form-item label="车辆用途:">
                <span class="cont">{{ item.transportPurpose }}</span>
              </el-form-item>
              <el-form-item label="预约车型:">
                <span class="cont">{{ item.transportCarType }}</span>
              </el-form-item>
              <el-form-item label="预约时间:">
                <span class="cont">{{ item.appointmentTime }}</span>
              </el-form-item>
              <el-form-item label="接运地点:">
                <span class="cont">{{ item.transportPlace }}</span>
              </el-form-item>
            </el-row>
            <el-row :gutter="5">
              <el-form-item label="车牌号:">
                <span class="cont">{{ item.transportCarNo }}</span>
              </el-form-item>
              <el-form-item label="司机:">
                <span class="cont">{{ item.driverUserName }}</span>
              </el-form-item>
              <el-form-item label="司机电话:">
                <span class="cont">{{ item.driverUserTelephone }}</span>
              </el-form-item>
              <el-form-item label="抬尸工:">
                <span class="cont">{{ item.transportTaskPorterNames }}</span>
              </el-form-item>
            </el-row>
            <el-row :gutter="5">
              <el-form-item label="任务状态:">
                <span class="cont">{{ item.processState }}</span>
              </el-form-item>
              <el-form-item label="出车时间:">
                <span class="cont">{{ item.departureTime }}</span>
              </el-form-item>
              <el-form-item label="回车时间:">
                <span class="cont">{{ item.returnTime }}</span>
              </el-form-item>
              <el-form-item label="接运联系人:">
                <span class="cont">{{ item.transportLinkman }}</span>
              </el-form-item>
              <el-form-item label="联系人电话:">
                <span class="cont">{{ item.transportTelephone }}</span>
              </el-form-item>
              <el-form-item style="float: right;">
                <el-button
                  size="small"
                  type="primary"
                  @click.native.prevent="CarryInfoEdit(item)" v-if="btnlimits.btnEditTransportTask">编辑
                </el-button>
                <el-button v-if="btnlimits.btnDeleteTransportTask"
                           @click.native.prevent="CarryInfodeleteRow(item)"
                           type="primary" plain
                           size="small">
                  删除
                </el-button>
              </el-form-item>
            </el-row>
            <el-row style="display: flex;">
              <tableList :tableData="item.charges.goodsServices" style="width: 100%;"></tableList>
            </el-row>
          </div>
        </div>
        <div class="PageItem" v-if="btnlimits.coldStorageDialog">
          <el-row class="PageInfo">
            <el-col :span="21"><i class="info-bar"></i>冷藏信息</el-col>
            <el-col :span="3" style="text-align: right">
              <el-button type="success" icon="el-icon-plus" @click="checkCold()" v-if="btnlimits.btnAddColdStorage">
                追加冷藏任务
              </el-button>
            </el-col>
          </el-row>
          <div class="border1" v-if="ruleForm.coldStorageTasks.length>0"
               v-for="(item,index) in ruleForm.coldStorageTasks">
            <el-row :gutter="5">
              <el-form-item label="冷藏柜类型:" prop="name">
                <span class="cont">{{ item.equipmentType }}</span>
              </el-form-item>
              <el-form-item label="冷柜号:" prop="name">
                <span class="cont">{{ item.equipmentCode }}</span>
              </el-form-item>
              <el-form-item label="入藏时间:" prop="name">
                <span class="cont">{{ item.appointmentInTime }}</span>
              </el-form-item>
              <el-form-item label="出藏时间:" prop="name">
                <span class="cont">{{ item.appointmentOutTime }}</span>
              </el-form-item>
            </el-row>
            <el-row :gutter="5">
              <el-form-item label="冷藏状态:" prop="name">
                <span class="cont">{{ item.processState }}</span>
              </el-form-item>
              <el-form-item style="float:right;">
                <el-button type="primary"
                           size="small"
                           @click.native.prevent="ColdStorageInfoEdit(item)" v-if="btnlimits.btnEditColdStorage">编辑
                </el-button>
                <el-button type="primary" plain
                           @click.native.prevent="ColdStoragedeleteRow(item)" v-if="btnlimits.btnDeleteColdStorage"
                           size="small">
                  删除
                </el-button>
              </el-form-item>
            </el-row>
            <el-row style="display:flex;">
              <tableList :tableData="item.charges.goodsServices" style="width: 100%;"></tableList>
            </el-row>
          </div>
        </div>
        <div class="PageItem" v-if="btnlimits.farewellMournDialog">
          <el-row class="PageInfo">
            <el-col :span="21"><i class="info-bar"></i>告别厅信息</el-col>
            <el-col :span="3" style="text-align: right">
              <el-button type="success" icon="el-icon-plus" @click="AddFareWell()" v-if="btnlimits.btnAddFarewellMourn">
                追加告别厅　
              </el-button>
            </el-col>
          </el-row>
          <div class="border1" v-if="ruleForm.farewellMournTasks.length>0"
               v-for="(item,index) in ruleForm.farewellMournTasks">
            <el-row :gutter="5">
              <el-form-item label="告别厅类型:" prop="name">
                <span class="cont">{{ item.hallType }}</span>
              </el-form-item>
              <el-form-item label="告别厅:" prop="name">
                <span class="cont">{{ item.hallName }}</span>
              </el-form-item>
              <el-form-item label="开始时间:" prop="name">
                <span class="cont">{{ item.appointmentInTime }}</span>
              </el-form-item>
              <el-form-item label="截止时间:" prop="name">
                <span class="cont">{{ item.appointmentOutTime }}</span>
              </el-form-item>
            </el-row>
            <el-row :gutter="5">
              <el-form-item label="礼厅状态:" prop="name">
                <span class="cont">{{ item.processState }}</span>
              </el-form-item>
              <el-form-item style="float:right;">
                <el-button
                  size="small"
                  type="primary"
                  @click.native.prevent="FareWellEdit(item)" v-if="btnlimits.btnEditFarewellMourn">编辑
                </el-button>
                <el-button
                  @click.native.prevent="FareWelldeleteRow(item)" v-if="btnlimits.btnDeleteFarewellMourn"
                  size="small" plain
                  type="primary">
                  删除
                </el-button>
              </el-form-item>
            </el-row>
            <el-row style="display: flex;">
              <tableList :tableData="item.charges.goodsServices" style="width: 100%;"></tableList>
            </el-row>
          </div>
        </div>

        <div class="PageItem" v-if="btnlimits.faceLiftDialog">
          <el-row class="PageInfo">
            <el-col :span="21"><i class="info-bar"></i>整容信息</el-col>
            <el-col :span="3" style="text-align: right">
              <el-button type="success" icon="el-icon-plus" @click="AddFace()" v-if="btnlimits.btnAddFaceLift">追加整容任务
              </el-button>
            </el-col>
          </el-row>
          <div class="border1" v-if="ruleForm.faceLiftTasks.length">
            <el-row>
              <el-table
                :cell-style="cellStyle"
                :data="ruleForm.faceLiftTasks"
                stripe
                border :header-cell-style="{background:'rgb(246,247,251)',color:'#606266'}">
                <el-table-column align='center' prop="itemName" label="收费项目" width="100">
                </el-table-column>
                <el-table-column
                  prop="itemPrice"
                  align='right'
                  label="单价"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="itemNumber"
                  align='right'
                  label="数量"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="itemUnit"
                  align='center'
                  label="单位"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="itemCharge"
                  align='right'
                  label="总金额"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="discountCharge"
                  align='right'
                  label="优惠"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="benefitCharge"
                  align='right'
                  label="减免"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="asSettled"
                  align='center'
                  label="结算状态"
                  width="80">
                  <template slot-scope="{row}">
                    <div v-if="row.itemName">
                      <span v-if="row.asUnsettled==1" style="color: #f00;">不可结算</span>
                      <span v-else-if="row.asSettled==0">未结算</span>
                      <span v-else-if="row.asSettled==1">已结算</span>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align='center'
                  width="80">
                  <template slot-scope="{row}">
                    <div v-if="row.asSettled==0">
                      <el-button
                        @click.native.prevent="FacedeleteRow(row)" v-if="btnlimits.btnDeleteFaceLift"
                        type="text"
                        size="small">
                        删除
                      </el-button>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column align='center' prop="itemName1" label="收费项目" width="100">
                </el-table-column>
                <el-table-column
                  prop="itemPrice1"
                  align='right'
                  label="单价"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="itemNumber1"
                  align='right'
                  label="数量"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="itemUnit1"
                  align='center'
                  label="单位"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="itemCharge1"
                  align='right'
                  label="总金额"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="discountCharge1"
                  align='right'
                  label="优惠"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="benefitCharge1"
                  align='right'
                  label="减免"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="asSettled1"
                  align='center'
                  label="结算状态"
                  width="80">
                  <template slot-scope="{row}">
                    <div v-if="row.itemName1">
                      <span v-if="row.asUnsettled1==1" style="color: #f00;">不可结算</span>
                      <span v-else-if="row.asSettled1==0">未结算</span>
                      <span v-else-if="row.asSettled1==1">已结算</span>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align='center'
                  width="80">
                  <template slot-scope="{row}">
                    <div v-if="row.asSettled1==0">
                      <el-button
                        @click.native.prevent="FacedeleteRow(row)" v-if="btnlimits.btnDeleteFaceLift"
                        type="text"
                        size="small">
                        删除
                      </el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
          </div>
        </div>
        <div class="PageItem" v-if="btnlimits.cremationDialog">
          <el-row class="PageInfo">
            <el-col :span="21"><i class="info-bar"></i>火化信息</el-col>
            <el-col :span="3" style="text-align: right">
              <el-button type="success" icon="el-icon-plus" @click="checkFrie()" v-if="btnlimits.btnAddCremation">
                预约火化任务
              </el-button>
            </el-col>
          </el-row>
          <div class="border1" v-if="ruleForm.cremationTasks.length>0" v-for="(item,index) in ruleForm.cremationTasks">
            <el-row :gutter="5">
              <el-form-item label="火化炉类型:" prop="name">
                <span class="cont">{{ item.furnaceType }}</span>
              </el-form-item>
              <el-form-item label="是否预约:" prop="name">
                <span class="cont">{{ item.asAppointment == '0' ? "否" : "是" }}</span>
              </el-form-item>
            </el-row>
            <el-row :gutter="5">
              <el-form-item label="预约火化日期:" prop="name">
                <span class="cont">{{ item.appointmentDate + " " + item.appointmentTimeSegment }}</span>
              </el-form-item>
              <el-form-item label="骨灰处理方式:" prop="name">
                <span class="cont">{{ item.ashHandleType }}</span>
              </el-form-item>
              <el-form-item label="骨灰去向:" prop="name">
                <span class="cont">{{ item.ashWhereabouts }}</span>
              </el-form-item>
              <el-form-item style="float: right;">
                <el-button
                  size="small"
                  type="primary"
                  @click.native.prevent="FireEdit(item)" v-if="btnlimits.btnEditCremation">编辑
                </el-button>
                <el-button
                  @click.native.prevent="FiredeleteRow(item)" v-if="btnlimits.btnDeleteCremation"
                  type="primary" plain
                  size="small">
                  删除
                </el-button>
              </el-form-item>
            </el-row>
            <el-row style="display: flex;">
              <tableList :tableData="item.charges.goodsServices" style="width: 100%;"></tableList>
            </el-row>
          </div>
        </div>
        <div class="PageItem" v-if="btnlimits.goodsServiceDialog" :style="{marginBottom:fixedFlag?'80px':'20px'}">
          <el-row class="PageInfo">
            <el-col :span="21"><i class="info-bar"></i>丧葬用品</el-col>
            <el-col :span="3" style="text-align: right">
              <el-button type="success" icon="el-icon-plus" @click="addGoods()"
                         v-if="btnlimits.btnAddFuneralSupplies">新增用品
              </el-button>
            </el-col>
          </el-row>
          <div class="border1" v-if="ruleForm.goodsItems.length>0">
            <el-row>
              <el-table
                :cell-style="cellStyle"
                :data="ruleForm.goodsItems"
                stripe
                border :header-cell-style="{background:'rgb(246,247,251)',color:'#606266'}">
                <el-table-column align='center' prop="itemName" label="收费项目" width="100">
                </el-table-column>
                <el-table-column
                  prop="itemPrice"
                  align='right'
                  label="单价"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="itemNumber"
                  align='right'
                  label="数量"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="itemUnit"
                  align='center'
                  label="单位"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="itemCharge"
                  align='right'
                  label="总金额"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="discountCharge"
                  align='right'
                  label="优惠"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="benefitCharge"
                  align='right'
                  label="减免"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="asSettled"
                  align='center'
                  label="结算状态"
                  width="80">
                  <template slot-scope="{row,$index}">
                    <div v-if="row.itemName">
                      <span v-if="row.asUnsettled==1" style="color: #f00;">不可结算</span>
                      <span v-else-if="row.asSettled==0">未结算</span>
                      <span v-else-if="row.asSettled==1">已结算</span>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align='center'>
                  <template slot-scope="{row,$index}">
                    <div v-if="row.asSettled==0">
                      <el-button
                        @click.native.prevent="GoodsServicedeleteRow(row.id,row.version)"
                        v-if="btnlimits.btnDeleteFuneralSupplies"
                        type="text"
                        size="small">
                        删除
                      </el-button>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column align='center' prop="itemName1" label="收费项目" width="100">
                </el-table-column>
                <el-table-column
                  prop="itemPrice1"
                  align='right'
                  label="单价"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="itemNumber1"
                  align='right'
                  label="数量"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="itemUnit1"
                  align='center'
                  label="单位"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="itemCharge1"
                  align='right'
                  label="总金额"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="discountCharge1"
                  align='right'
                  label="优惠"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="benefitCharge1"
                  align='right'
                  label="减免"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="asSettled1"
                  align='center'
                  label="结算状态"
                  width="80">
                  <template slot-scope="{row}">
                    <div v-if="row.itemName1">
                      <span v-if="row.asUnsettled1==1" style="color: #f00;">不可结算</span>
                      <span v-else-if="row.asSettled1==0">未结算</span>
                      <span v-else-if="row.asSettled1==1">已结算</span>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align='center'>
                  <template slot-scope="{row}">
                    <div v-if="row.asSettled1==0">
                      <el-button
                        @click.native.prevent="GoodsServicedeleteRow(row.id1,row.version1)"
                        v-if="btnlimits.btnDeleteFuneralSupplies"
                        type="text"
                        size="small">
                        删除
                      </el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
          </div>
        </div>
        <div class="PageItem" v-if="btnlimits.goodsServiceDialog" :style="{marginBottom:fixedFlag?'80px':'20px'}">
          <el-row class="PageInfo">
            <el-col :span="21"><i class="info-bar"></i>殡仪服务</el-col>
            <el-col :span="3" style="text-align: right">
              <el-button type="success" icon="el-icon-plus" @click="addService()"
                         v-if="btnlimits.btnAddFuneralSupplies">新增服务
              </el-button>
            </el-col>
          </el-row>
          <div class="border1" v-if="ruleForm.serviceItems.length>0">
            <el-row>
              <el-table
                :cell-style="cellStyle"
                :data="ruleForm.serviceItems"
                stripe
                border :header-cell-style="{background:'rgb(246,247,251)',color:'#606266'}">
                <el-table-column align='center' prop="itemName" label="收费项目" width="100">
                </el-table-column>
                <el-table-column
                  prop="itemPrice"
                  align='right'
                  label="单价"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="itemNumber"
                  align='right'
                  label="数量"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="itemUnit"
                  align='center'
                  label="单位"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="itemCharge"
                  align='right'
                  label="总金额"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="discountCharge"
                  align='right'
                  label="优惠"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="benefitCharge"
                  align='right'
                  label="减免"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="asSettled"
                  align='center'
                  label="结算状态"
                  width="80">
                  <template slot-scope="{row,$index}">
                    <div v-if="row.itemName">
                      <span v-if="row.asUnsettled==1" style="color: #f00;">不可结算</span>
                      <span v-else-if="row.asSettled==0">未结算</span>
                      <span v-else-if="row.asSettled==1">已结算</span>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align='center'>
                  <template slot-scope="{row,$index}">
                    <div v-if="row.asSettled==0">
                      <el-button
                        @click.native.prevent="GoodsServicedeleteRow(row.id,row.version)"
                        v-if="btnlimits.btnDeleteFuneralSupplies"
                        type="text"
                        size="small">
                        删除
                      </el-button>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column align='center' prop="itemName1" label="收费项目" width="100">
                </el-table-column>
                <el-table-column
                  prop="itemPrice1"
                  align='right'
                  label="单价"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="itemNumber1"
                  align='right'
                  label="数量"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="itemUnit1"
                  align='center'
                  label="单位"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="itemCharge1"
                  align='right'
                  label="总金额"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="discountCharge1"
                  align='right'
                  label="优惠"
                  width="100">
                </el-table-column>
                <el-table-column
                  prop="benefitCharge1"
                  align='right'
                  label="减免"
                  width="80">
                </el-table-column>
                <el-table-column
                  prop="asSettled1"
                  align='center'
                  label="结算状态"
                  width="80">
                  <template slot-scope="{row}">
                    <div v-if="row.itemName1">
                      <span v-if="row.asUnsettled1==1" style="color: #f00;">不可结算</span>
                      <span v-else-if="row.asSettled1==0">未结算</span>
                      <span v-else-if="row.asSettled1==1">已结算</span>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align='center'>
                  <template slot-scope="{row}">
                    <div v-if="row.asSettled1==0">
                      <el-button
                        @click.native.prevent="GoodsServicedeleteRow(row.id1,row.version1)"
                        v-if="btnlimits.btnDeleteFuneralSupplies"
                        type="text"
                        size="small">
                        删除
                      </el-button>
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-row>
          </div>
        </div>
        <div :class="{PageItem:!fixedFlag}">
          <el-row :class="{fixed:fixedFlag}" class="totalmoney"
                  :style="{width:fixedFlag? `${pageItemWidth}px`:'100%',paddingLeft:fixedFlag? '20px':0}">
            <div class="font16" style="text-align:right;">
              <div style="display: inline-block;height: 80px;line-height: 80px;vertical-align: bottom;">
                总费用合计:<span class="totalw">{{ Charge.total }}</span>元
              </div>
              <div style="padding-left:30px;display: inline-block;">
                <div style="line-height: 40px;">
                  已结算:<span class="totalw">{{ Charge.Settled }}</span>元，
                  优惠:<span class="totalw">{{ Charge.discountCharge }}</span>元，
                  减免:<span class="totalw">{{ Charge.benefitCharge }}</span>元，
                  实收合计:<span class="totalw">{{ Charge.realityCharge }}</span>元
                </div>
                <div style="line-height: 40px;">
                  未结算:<span class="totalw">{{ Charge.unSettled }}</span>元，
                  优惠:<span class="totalw">{{ Charge.unDiscountCharge }}</span>元，
                  减免:<span class="totalw">{{ Charge.unBenefitCharge }}</span>元，
                  待付金额:<span class="totalw totalfont">{{ Charge.unrealityCharge }}</span>元
                </div>
              </div>
            </div>
            <hr>
            <el-row :gutter="30" style="text-align: center;margin:30px 0; height: 40px;">
              <el-switch style="float: left;"
                         v-model="fixedFlag"
                         inactive-text="解除锁定">
              </el-switch>
              <span style="float:right;">
                <el-button type="primary" plain v-if="btnlimits.btnPrintDeadQRCode" @click="getCremationArchivesCode">打印逝者二维码</el-button>
              <el-button type="primary" plain v-if="btnlimits.btnPrintContract"
                         @click="getPrintContact">打印殡葬合同</el-button>
                <el-button type="primary" plain v-if="btnlimits.btnPrintServiceAgreement" @click="getServiceAgreement">打印服务协议单</el-button>
                 <el-button type="primary" v-if="btnlimits.btnPrintAbatementList" plain @click="PrintAbatementList">
              打印减免基本殡葬服务费用申请表
            </el-button>
              <el-button type="primary" v-if="btnlimits.btnGoCostSettlement" @click="TotalMoney">费用结算</el-button>
              <el-button type="primary" v-if="btnlimits.btnImmediatelySettlement" @click="NowPay">直接缴费</el-button>
              </span>

            </el-row>
          </el-row>
        </div>

      </el-form>
    </div>
    <!--background-color:#efefef;-->

    <CarryInfoDialog :DialogAddCarry="DialogAddCarry" :ruleItems="ruleItems" :dicts="dicts" :taskallInfo="taskallInfo"
                     :CarryAddFlag="CarryAddFlag" :OldCarId="OldCarId" :transportCarTypes="transportCarTypes"
                     :cars="cars" :driverUsers="driverUsers" :transportTaskPorters="transportTaskPorters"
                     :transportPurposes="transportPurposes" :processStates="processStates"></CarryInfoDialog>
    <ColdStorageDialog :DialogColdStorage="DialogColdStorage" :funeralDead="funeralDead" :ruleItems="ruleItems"
                       :processStates="processStates" :ColdStorageInfo="ColdStorageInfo"
                       :ColdStorageAddFlag="ColdStorageAddFlag"
                       :ProcessStateCodeOld="ProcessStateCodeOld"></ColdStorageDialog>
    <WakeUpDialog :DialogWakeUp="DialogWakeUp" :WakeUpInfo="WakeUpInfo" :hallStatus="hallStatus" :ruleItems="ruleItems"
                  :WakeUpAddFlag="WakeUpAddFlag" :ProcessStateWakeUpOld="ProcessStateWakeUpOld"></WakeUpDialog>
    <FareWellDialog :DialogFareWell="DialogFareWell" :FareWellInfo="FareWellInfo" :hallStatus="hallStatus"
                    :ruleItems="ruleItems" :FareWellAddFlag="FareWellAddFlag"
                    :ProcessStateFareWellOld="ProcessStateFareWellOld"></FareWellDialog>
    <FireDialog :DialogFire="DialogFire" :ruleItems="ruleItems" :ruleItemsMini="ruleItemsMini"
                :cremationChargeTypes="cremationChargeTypes" :ashHandleTypes="ashHandleTypes"
                :ashWhereabouts="ashWhereabouts" :FireInfo="FireInfo" :FireAddFlag="FireAddFlag"></FireDialog>
    <FaceDialog :DialogFace="DialogFace" :FaceItems="FaceItems" :business-code="businessCode"></FaceDialog>
    <NowPayDialog @refresh="searchData(businessCode)" :NowPayFlag="NowPayFlag" :multipleSelection="Unsettled"
                  :businessCode="businessCode"></NowPayDialog>
    <GoodsServiceDialog :DialogGoodsService="DialogGoodsService" :GoodsServiceItems="GoodsServiceItems"
                        :business-code="businessCode" :DialogGoodsServiceTitleName="DialogGoodsServiceTitleName">
    </GoodsServiceDialog>
    <SearchDialog :DialogSearch="DialogSearch" :copyCremationTypes="dictionary.cremation_type"></SearchDialog>
  </div>
</template>

<script>
import CarryInfoDialog from "../dialog/CarryInfoDialog";
import ColdStorageDialog from "../dialog/ColdStorageDialog";
import WakeUpDialog from "../dialog/WakeUpDialog";
import FareWellDialog from "../dialog/FareWellDialog";
import FireDialog from "../dialog/FireDialog";
import FaceDialog from "../dialog/FaceDialog";
import NowPayDialog from "../dialog/NowPayDialog";
import GoodsServiceDialog from "../dialog/GoodsServiceDialog";
import tableList from "@/components/Table";
import {dataFormate} from "@/utils/index";
import SearchDialog from '../dialog/SearchDialog'

import * as Type from "@/api/service";
import * as mournService from "@/api/mournService";
import {toFixed} from "@/utils/tofixed";
import {
  tableDataDoubleCol,
  tableDataDoubleColArry,
} from "@/utils/tableDataFilter";
import {getLodop} from "@/utils/lodopFuncs";
import table from "../../../mock/table";
import {EventBus} from '@/utils/eventBus'

export default {
  name: "Service",
  components: {
    CarryInfoDialog,
    ColdStorageDialog,
    WakeUpDialog,
    FareWellDialog,
    FireDialog,
    FaceDialog,
    NowPayDialog,
    GoodsServiceDialog,
    tableList,
    SearchDialog,
  },
  data() {
    // 定义变量source
    return {
      //殡仪服务及丧葬用品标题名字
      DialogGoodsServiceTitleName: "",
      DialogSearch: false, //业务查询
      pageItemWidth: 0, //计算fixed宽度
      pageItemBottom: 0, //计算fixed距离上面的大小
      loading: false,
      dictionary: {}, //字典
      businessCode: "",
      businessCodeTitle: "",
      ruleForm: {
        funeralDead: {
          id: 0,
          businessCode: "",
          deadName: "",
          certificateNo: "",
          deadGender: "",
          exemptionType: "",
          transportPlace: "",
          deathCertificateNo: "",
          deathCause: "", //死亡原因
          asArrived: 0,
          transportArrivedTime: "",
        },
        familyMember: {
          id: 0,
          memberName: "",
          telephone: "",
          certificateNo: "",
          memberRelation: "",
        },
        familyAgent: {
          id: 0,
          //承办人单位姓名
          agentUnitName: "",
          //承办人姓名
          agentName: "",
          telephone: "",
          certificateNo: "",
          agentRelation: "",
        },
        transportTasks: [],
        coldStorageTasks: [],
        faceLiftTasks: [],
        wakeMournTasks: [],
        farewellMournTasks: [],
        cremationTasks: [],
        funeralSuppliesTasks: [],
        //新增丧葬用品
        goodsItems: [],
        //新增丧葬服务
        serviceItems: []
      },
      ruleFormCalc: {
        funeralDead: {
          id: 0,
          businessCode: "",
          deadName: "",
          certificateNo: "",
          deadGender: "",
          exemptionType: "",
          transportPlace: "",
          deathCertificateNo: "",
          deathCause: "", //死亡原因
          asArrived: 0,
          transportArrivedTime: "",
        },
        familyMember: {
          id: 0,
          memberName: "",
          telephone: "",
          certificateNo: "",
          memberRelation: "",
        },
        familyAgent: {
          id: 0,
          //承办人单位姓名
          agentUnitName: "",
          //承办人姓名
          agentName: "",
          telephone: "",
          certificateNo: "",
          agentRelation: "",
        },
        transportTasks: [],
        coldStorageTasks: [],
        faceLiftTasks: [],
        wakeMournTasks: [],
        farewellMournTasks: [],
        cremationTasks: [],
        funeralSuppliesTasks: [],
        //新增丧葬用品
        goodsItems: [],
        //新增丧葬服务
        serviceItems: []
      },

      rules: {
        name: [
          {required: true, message: "请输入活动名称", trigger: "blur"},
          {min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur"},
        ],
      },
      CarryInfo: [
        {
          id: 1,
          businessCode: "00123",
          appointmentTime: "",
          transportCarTypeCode: "测试",
          transportCarId: 1,
          licensePlate: "测试",
          driverUserId: 1,
          driverUserName: "测是",
          driverUserTelephone: "123456789",
          transportTaskPorter: [1, 2],
          transportPurposeCode: 12,
          transportPlace: "测试",
          processStateCode: "123",
          departureTime: "",
          returnTime: "123",
          transportDistance: 0,
          remark: "测试",
          charges: {
            shippingCharges: {
              id: 1,
              businessCode: "123",
              serviceItemId: 1,
              itemPrice: 10,
              itemNumber: 11,
              itemUnit: "个",
              itemCharge: 12,
              discountCharge: 13,
              realityCharge: 11111,
              asSettled: 0,
            },
            goodsServices: [],
          },
        },
      ], //接运任务

      //加载接运任务数据
      taskallInfo: {
        transportTask: {
          id: 0,
          businessCode: "",
          appointmentTime: "",
          transportCarTypeCode: "",
          transportCarId: "",
          carNo: "",
          driverUserId: "",
          driverUserName: "",
          driverUserTelephone: "",
          transportTaskPorter: [],
          transportTaskPorterNames: "",
          transportPurposeCode: "",
          transportPlace: "",
          processStateCode: "",
          departureTime: "",
          returnTime: "",
          transportDistance: "",
          transportLinkman: "",
          transportTelephone: "",
          rule_number: "",
          rule_unit: "",
          rule_code: "",
          rule_remark: "",
          remark: "",
          calculateRule: "",
          version: 0, //数据版本，新增时传0
          charges: {
            businessCharge: {
              //用于计算
              id: 0,
              serviceItemId: 0,
              itemPrice: "",
              itemNumber: "",
              itemUnit: "",
              itemCharge: "",
              discountCharge: "",
              realityCharge: "",
              asSettled: 1,
              version: 0,
            },
            goodsServices: [],
          },
        },
        dicts: {
          transport_car_task_status: [
            {
              code: 0,
              text: 1,
            },
          ],
          transport_car_use: [
            {
              code: 0,
              text: 1,
            },
          ],
        },
        users: {
          transportTaskDriverUser: {},
          transportTaskPorter: [{}],
        },
        serviceItems: {
          use_in_transport_task: [],
        },
      }, //字典传值对象
      dicts: {
        transport_car_type: [], //车辆类型
        transport_car_use: [], //用途
      },
      //加载冷藏任务数据
      ColdStorageInfo: {
        coldStorage: {
          id: 0,
          businessCode: "",
          equipmentTypeCode: "",
          equipmentTypeText: "",
          equipmentId: "",
          processStateCode: "",
          processStateText: "",
          appointmentInTime: "",
          appointmentOutTime: "",
          version: 0,
          calculateRule: "",
          charges: {
            businessCharge: {
              id: 0,
              serviceItemId: 0,
              itemPrice: 0,
              itemNumber: 0,
              itemUnit: "",
              itemCharge: 0,
              discountCharge: 0,
              realityCharge: 0,
              asSettled: 0,
              version: 0,
            },
            goodsServices: [],
          },
        },
        dicts: {
          sex: [
            {
              code: 0,
              text: "",
            },
          ],
          certificates: [
            {
              code: 0,
              text: "",
            },
          ],
          other: [
            {
              code: 0,
              text: "",
            },
          ],
        },
        serviceItems: {
          useInColdStorage: [
            {
              id: 0,
              itemName: "",
              itemPrice: 0,
              itemNumber: 0,
              itemUnit: "",
            },
          ],
        },
      },
      //守灵厅
      WakeUpInfo: {
        wakeMourn: {
          id: 0,
          businessCode: "",
          businessType: "",
          hallTypeCode: "", //礼厅类型编码
          hallId: 0,
          processStateCode: 0,
          appointmentInTime: "",
          appointmentOutTime: "",
          version: 0,
          calculateRule: "",
          charges: {
            businessCharge: {
              id: 0,
              serviceItemId: 0,
              itemPrice: 0,
              itemNumber: 0,
              itemUnit: "",
              itemCharge: 0,
              discountCharge: 0,
              realityCharge: 0,
              asSettled: 0,
              version: 0,
            },
            goodsServices: [],
          },
        },
        dicts: {},
        serviceItems: {
          useInMournCeremony: [],
        },
      },
      //告别厅
      FareWellInfo: {
        farewellMourn: {
          id: 0,
          businessCode: "",
          businessType: "",
          hallTypeCode: "", //礼厅类型编码
          hallId: 0,
          processStateCode: 0,
          appointmentInTime: "",
          appointmentOutTime: "",
          version: 0,
          calculateRule: "",
          charges: {
            businessCharge: {
              id: 0,
              serviceItemId: 0,
              itemPrice: 0,
              itemNumber: 0,
              itemUnit: "",
              itemCharge: 0,
              discountCharge: 0,
              realityCharge: 0,
              asSettled: 0,
              version: 0,
            },
            goodsServices: [],
          },
        },
        dicts: {},
        serviceItems: {
          useInMournCeremony: [],
        },
      },
      //火化
      FireInfo: {
        cremation: {
          id: 0,
          businessCode: "",
          furnaceTypeCode: "43",
          furnaceId: "",
          asAppointment: 0,
          appointmentStartTime: "",
          appointmentFinishTime: "",
          cremationNo: "",
          randomCode: "",
          ashHandleTypeCode: "",
          ashWhereaboutsCode: "",
          version: 0,
          charges: {
            businessCharge: {
              id: 0,
              serviceItemId: 0,
              itemPrice: 0,
              itemNumber: 0,
              itemUnit: "",
              itemCharge: 0,
              discountCharge: 0,
              realityCharge: 0,
              asSettled: 0,
              version: 0,
            },
            goodsServices: [],
          },
        },
        dicts: {},
        serviceItems: {
          use_in_cremation: [],
        },
      },
      btnlimits: {
        btnBusinessCodeScanning: true, //业务编码扫码按钮
        btnPrintDeadQRCode: true, //打印逝者二维码按钮
        btnPrintServiceAgreement: true, //打印服务协议单按钮
        btnGoCostSettlement: true, //费用结算按钮
        btnImmediatelySettlement: true, //直接缴费按钮
        btnAddTransportTask: true, //新增接运
        btnEditTransportTask: true, //接运信息
        btnDeleteTransportTask: true, //删除接运信息
        btnAddFuneralBusiness: true,
        btnEditColdStorage: true, //冷藏
        btnAddColdStorage: true,
        btnDeleteColdStorage: true,
        btnAddFaceLift: true, //整容
        btnDeleteFaceLift: true,
        btnAddWakeMourn: true, //礼厅
        btnEditWakeMourn: true,
        btnDeleteWakeMourn: true,
        btnAddFarewellMourn: true,
        btnEditFarewellMourn: true,
        btnDeleteFarewellMourn: true,
        btnAddCremation: true, //预约火化
        btnEditCremation: true,
        btnDeleteCremation: true,
        btnAddFuneralSupplies: true, //丧葬用品
        btnDeleteFuneralSupplies: true,
        //打印减免表
        btnPrintAbatementList: true,
        btnBusinessSearch: true, //业务查询
      }, //按钮权限

      //新增丧葬用品服务
      GoodsServiceItems: [],
      //新增整容任务
      FaceItems: [],
      ProcessStateCodeOld: 0, //旧的冷藏状态
      ProcessStateWakeUpOld: 0, //旧的守灵状态
      ProcessStateFareWellOld: 0, //旧的告别状态
      CarryAddFlag: false, //新的接运任务
      ColdStorageAddFlag: false, //新的冷藏任务
      WakeUpAddFlag: false, //新的守灵厅
      FareWellAddFlag: false, //新的告别厅
      FireAddFlag: false, //新的火化
      DialogAddCarry: false, //接运任务对话框
      DialogColdStorage: false,
      DialogFace: false,
      DialogWakeUp: false,
      DialogFareWell: false,
      DialogFire: false,
      DialogGoodsService: false,
      NowPayFlag: false, //直接付款
      Unsettled: [], //未结算项直接付款
      moreFlag: false, //折叠显示标志
      fixedFlag: false, //底部固定
      ruleItems: [], //收费规则
      ruleItemsMini: [], //合并后的火化类型
      ruleChargeItems: [], //火化计费类型收费规则
      cremationTypes: [], //火化类型
      cremationChargeTypes: [], //火化计费类型
      ashHandleTypes: [], //骨灰处理方式
      ashWhereabouts: [], //骨灰去向
      processStates: [], //冷藏状态
      funeralDead: {}, //逝者信息
      OldCarId: null, //旧的车辆编号
      transportCarTypes: [], //预约车型名称集合
      cars: [], //车辆牌号名称集合
      driverUsers: [], //司机名称集合
      transportTaskPorters: [], //抬尸工集合
      transportPurposes: [], //车辆用途名称集合
      hallStatus: [], //守灵状态集合
    };
  },

  mounted() {
    //页面初始化方法
    //按钮权限
    this.btnlimits = this.$route.meta.buttons;
    //遍历属性赋值将true与false字符串转换成布尔型的值
    for (let key of Object.keys(this.btnlimits)) {
      this.btnlimits[key] =
        this.btnlimits[key] || this.btnlimits[key] == "true" ? true : false;
    }
    this.$store
      .dispatch("user/getdictionary")
      .then((res) => {
        //获取字典数据
        this.dictionary = res;
        this.$set(this.dictionary, res);
      })
      .catch(() => console.log("promise catch err"));
    this.businessCode = this.$store.getters.businessCode;
    console.log(this.businessCode, 1208);
    // if (!this.businessCode) {
    //   document.getElementById('serviceSearch').value=this.businessCode
    // }
    if (this.businessCode != null && this.businessCode != "") {
      this.searchData(this.businessCode);
    }
    //businessCode获得焦点
    // this.$refs["servicebusinessCode"].focus()
    /*获取宽度用来设置锁定总费用宽度*/
    let that = this;
    let width = document.getElementsByClassName("PageItem")[0].offsetWidth;
    if (width) {
      that.pageItemWidth = width;
    }
    window.onresize = function () {
      let width = document.getElementsByClassName("PageItem")[0].offsetWidth;
      if (width) {
        that.pageItemWidth = width;
      }
    };
  },
  beforeDestroy() {
    window.onresize = null;
  },
  methods: {
    // 单元格的 style 的回调方法
    cellStyle({row, column, rowIndex, columnIndex}) {
      if (columnIndex === 0 || columnIndex === 9) {
        return `background-color:rgb(250,250,250);`;
      } else {
        return "";
      }
    },
    //业务查询显示
    businessSearchShow() {
      this.DialogSearch = true;
    },
    selectChange() {
      //给业务编码设置焦点
      this.$refs.deathChange_ref.blur();
      this.$refs.servicebusinessCode.focus();
    },
    //事件方法执行
    //数据读取

    searchData(code) {
      //当用户输入业务编码时对业务编码赋值
      if (this.businessCodeTitle !== null && this.businessCodeTitle !== ""
        && this.businessCodeTitl !== this.businessCode) {
        this.businessCode = this.businessCodeTitle;
      }
      this.businessCodeTitle = "";
      code = this.businessCode;
      //this.$message(code);
      if (!code) {
        console.log(code, 1)
        this.$message("请输入业务编码");
        return;
      }
      //去掉空格
      code = this.trim(code);
      this.$store
        .dispatch("user/setbusinessCode", this.businessCode)
        .catch(() => console.log("promise catch err"));
      let postData = {
        businessCode: code,
      };
      this.loading = true;
      //this.businessCode="";
      Type["loadservicenegotiationwithbusinesscode"](postData)
        .then((response) => {
          // console.log(response, "接口数据源response")
          if (!response) {
            //this.$message("数据读取失败");
            // this.$refs['ruleForm'].resetFields();
            this.ruleForm.funeralDead = [];
            this.ruleForm.familyMember = [];
            this.ruleForm.familyAgent = [];
            this.ruleForm.coldStorageTasks = [];
            this.ruleForm.farewellMournTasks = [];
            this.ruleForm.faceLiftTasks = [];
            this.ruleForm.cremationTasks = [];
            this.ruleForm.funeralSuppliesTasks = [];
            this.ruleForm.goodsItems = [];
            this.ruleForm.serviceItems = [];
            this.loading = false;
            this.$store.commit('user/SET_BUSINESSCODE', '')
            EventBus.$emit("reLoad")
            return;
          }
          const {data} = response;
          // console.log(data, "接口数据源data")
          if (!data) {
            this.loading = false;
            this.$message("数据读取失败");

            return;
          }

          //数据读取成功
          if (data.funeralDead) {
            this.ruleForm.funeralDead = data.funeralDead;
            this.businessCode = data.funeralDead.businessCode;
          }
          if (data.familyMember) {
            this.ruleForm.familyMember = data.familyMember;
          }
          if (data.familyAgent) {
            this.ruleForm.familyAgent = data.familyAgent;
          }
          //接运信息
          if (data.transportTasks) {
            // this.ruleForm.transportTasks = data.transportTasks
            // console.log(this.ruleForm.transportTasks)
            /*接运费用添加到收费项目中*/
            if (data.transportTasks.length) {
              data.transportTasks.forEach((item) => {
                if (item.charges && item.charges.businessCharge) {
                  item.charges.goodsServices.push(item.charges.businessCharge);
                }
              });
            }
            /*用于计算*/
            this.ruleFormCalc.transportTasks = JSON.parse(
              JSON.stringify(data.transportTasks)
            );
            /*用于表格显示*/
            this.ruleForm.transportTasks = tableDataDoubleCol(
              data.transportTasks
            );
          } else {
            this.ruleForm.transportTasks = [];
            this.ruleFormCalc.transportTasks = [];
          }
          //冷藏
          if (data.coldStorageTasks) {
            /*冷藏费用添加到收费项目中*/
            if (data.coldStorageTasks.length) {
              data.coldStorageTasks.forEach((item) => {
                if (item.charges && item.charges.businessCharge) {
                  item.charges.goodsServices.push(item.charges.businessCharge);
                }
              });
            }
            /*用于计算*/
            this.ruleFormCalc.coldStorageTasks = JSON.parse(
              JSON.stringify(data.coldStorageTasks)
            );
            this.ruleForm.coldStorageTasks = tableDataDoubleCol(
              data.coldStorageTasks
            );
          } else {
            this.ruleFormCalc.coldStorageTasks = [];
            this.ruleForm.coldStorageTasks = [];
          }
          if (data.faceLiftTasks) {
            /*冷藏费用添加到收费项目中*/
            if (data.faceLiftTasks.length) {
              data.faceLiftTasks.forEach((item) => {
                if (item.charges && item.charges.businessCharge) {
                  item.charges.goodsServices.push(item.charges.businessCharge);
                }
              });
            }
            /*用于计算*/
            this.ruleFormCalc.faceLiftTasks = JSON.parse(
              JSON.stringify(data.faceLiftTasks)
            );
            this.ruleForm.faceLiftTasks = tableDataDoubleColArry(
              data.faceLiftTasks
            );
          } else {
            this.ruleForm.faceLiftTasks = [];
            this.ruleFormCalc.faceLiftTasks = [];
          }
          if (data.wakeMournTasks) {
            /*整容费用添加到收费项目中*/
            if (data.wakeMournTasks.length) {
              data.wakeMournTasks.forEach((item) => {
                if (item.charges && item.charges.businessCharge) {
                  item.charges.goodsServices.push(item.charges.businessCharge);
                }
              });
            }
            /*用于计算*/
            this.ruleFormCalc.wakeMournTasks = JSON.parse(
              JSON.stringify(data.wakeMournTasks)
            );
            this.ruleForm.wakeMournTasks = tableDataDoubleCol(
              data.wakeMournTasks
            );
          } else {
            this.ruleFormCalc.wakeMournTasks = [];
            this.ruleForm.wakeMournTasks = [];
          }
          if (data.farewellMournTasks) {
            /*费用添加到收费项目中*/
            if (data.farewellMournTasks.length) {
              data.farewellMournTasks.forEach((item) => {
                if (item.charges && item.charges.businessCharge) {
                  item.charges.goodsServices.push(item.charges.businessCharge);
                }
              });
            }
            //合并火化炉类型
            this.ruleItemsMini = this.pushRuleItemsMini(this.ruleItems);

            /*用于计算*/
            this.ruleFormCalc.farewellMournTasks = JSON.parse(
              JSON.stringify(data.farewellMournTasks)
            );
            this.ruleForm.farewellMournTasks = tableDataDoubleCol(
              data.farewellMournTasks
            );
          } else {
            this.ruleFormCalc.farewellMournTasks = [];
            this.ruleForm.farewellMournTasks = [];
          }
          //火化任务
          if (data.cremationTasks) {
            /*费用添加到收费项目中*/
            if (data.cremationTasks.length) {
              data.cremationTasks.forEach((item) => {
                if (item.charges && item.charges.businessCharge) {
                  item.charges.goodsServices.push(item.charges.businessCharge);
                }
              });
            }
            //火化计费类型规则
            if (data.ruleChargeItems) {
              this.ruleChargeItems = data.ruleChargeItems;
            }
            //火化类型funeralDead
            this.cremationTypes = this.FireInfo.dicts.cremation_type;
            //火化计费类型
            this.cremationChargeTypes = this.FireInfo.dicts.cremation_charge_type;
            //合并后的值
            this.cremationTypes = this.pushRuleItems(
              this.cremationTypes,
              data.funeralDead.cremationTypeCode,
              data.funeralDead.cremationType
            );
            //骨灰处理方式合并后的值
            this.ashHandleTypes = this.pushRuleItems(
              this.FireInfo.dicts.ashes_treatment,
              this.FireInfo.cremation.ashHandleTypeCode,
              this.FireInfo.cremation.ashHandleType
            );
            //骨灰去向合并后的值
            this.ashWhereabouts = this.pushRuleItems(
              this.FireInfo.dicts.ashes_whereabouts,
              this.FireInfo.cremation.ashWhereaboutsCode,
              this.FireInfo.cremation.ashWhereabouts
            );

            this.FireInfo.cremation.businessCode = this.businessCode;
            // this.DialogFire = true;

            /*用于计算*/
            this.ruleFormCalc.cremationTasks = JSON.parse(
              JSON.stringify(data.cremationTasks)
            );
            this.ruleForm.cremationTasks = tableDataDoubleCol(
              data.cremationTasks
            );
          } else {
            this.ruleFormCalc.cremationTasks = [];
            this.ruleForm.cremationTasks = [];
          }
          if (data.funeralSuppliesTasks) {
            /*费用添加到收费项目中*/
            if (data.funeralSuppliesTasks.length) {
              data.funeralSuppliesTasks.forEach((item) => {
                if (item.charges && item.charges.businessCharge) {
                  item.charges.goodsServices.push(item.charges.businessCharge);
                }
              });
            }
            /*用于计算*/
            this.ruleFormCalc.funeralSuppliesTasks = JSON.parse(
              JSON.stringify(data.funeralSuppliesTasks)
            );
            /*
                        this.ruleForm.funeralSuppliesTasks = tableDataDoubleColArry(
                          data.funeralSuppliesTasks
                        );
            */
            //在原有逻辑上进行遍历赋值 区分0，服务；1，物品
            this.ruleForm.serviceItems = [];
            this.ruleForm.goodsItems = [];
            // console.log(data.funeralSuppliesTasks, "服务及用品接口数据源");
            let serviceArray = [];
            let goodsArray = [];
            for (let z = 0; z < data.funeralSuppliesTasks.length; z++) {
              if (data.funeralSuppliesTasks[z].asGoods === 0) {
                // console.log(data.funeralSuppliesTasks[z],"赋值殡仪服务");
                //赋值殡仪服务
                serviceArray.push(data.funeralSuppliesTasks[z]);
              } else if (data.funeralSuppliesTasks[z].asGoods === 1) {
                // console.log(data.funeralSuppliesTasks[z],"赋值丧葬用品")
                //赋值丧葬用品
                goodsArray.push(data.funeralSuppliesTasks[z]);
              }
            }
            this.ruleForm.serviceItems = tableDataDoubleColArry(
              serviceArray
            );
            this.ruleForm.goodsItems = tableDataDoubleColArry(
              goodsArray
            );
            // console.log(this.ruleForm.serviceItems,"this.ruleForm.serviceItems");
            // console.log(this.ruleForm.goodsItems,"this.ruleForm.goodsItems");
          } else {
            this.ruleFormCalc.funeralSuppliesTasks = [];
            this.ruleForm.funeralSuppliesTasks = [];
            this.ruleForm.goodsItems = [];
            this.ruleForm.serviceItems = [];
          }
          this.loading = false;
          this.$forceUpdate();
        })
        .catch((error) => {
          this.loading = false;
          this.$message(error);
        });
    }, //去掉左右空格
    trim(str) {
      if (str == null) {
        return "";
      }
      return str.replace(/^\s*(.*?)[\s\n]*$/g, "$1");
    },
    //加载接运任务
    loadtransporttaskwithid() {
      let postData = {
        id: 0,
      };
      Type["loadtransporttaskwithid"](postData)
        .then((response) => {
          const {data} = response;
          if (!data) {
            this.$message("数据读取失败");
            return;
          }
          //   //数据读取成功
          this.ruleForm = this.ruleFormcopy;
        })
        .catch((error) => {
          this.$message(error);
        });
    },
    //点击编辑
    CarryInfoEdit(item) {
      this.CarryAddFlag = false;
      this.loadCarryInfotransporttaskall(item.id);
    },
    //点击删除接运任务
    CarryInfodeleteRow(item) {
      this.$confirm("删除信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //点击确定的操作(调用接口)
          let postData = {
            id: item.id,
            version: item.version,
          };
          Type["deletetransporttaskwithid"](postData)
            .then((response) => {
              let result = response;
              const {message} = result;
              this.$message(message);
              this.searchData(this.businessCode);
            })
            .catch((error) => {
              this.$message(error);
            });
        })
        .catch(() => {
          //几点取消的提示
        });
    },
    //追加接运任务
    AddCarry() {
      this.taskallInfo.transportTask = {
        id: 0,
        businessCode: "",
        appointmentTime: "",
        transportCarTypeCode: "",
        transportCarId: "",
        carNo: "",
        driverUserId: "",
        driverUserName: "",
        driverUserTelephone: "",
        transportTaskPorter: [],
        transportTaskPorterNames: "",
        transportPurposeCode: "",
        transportPlace: "",
        processStateCode: "",
        departureTime: "",
        returnTime: "",
        transportDistance: "",
        transportLinkman: "",
        transportTelephone: "",
        rule_number: "",
        rule_unit: "",
        rule_code: "",
        rule_remark: "",
        remark: "",
        calculateRule: "",
        version: 0, //数据版本，新增时传0
        charges: {
          businessCharge: {
            //用于计算
            id: 0,
            serviceItemId: 0,
            itemPrice: "",
            itemNumber: 1,
            itemUnit: "m",
            itemCharge: "",
            discountCharge: "",
            realityCharge: "",
            asSettled: 1,
            version: 0,
          },
          goodsServices: [],
        },
      };
      this.loadCarryInfotransporttaskall(0);
      this.CarryAddFlag = true;
    },
    //加载接运任务所有数据
    loadCarryInfotransporttaskall(transportTaskId) {
      let this_load = this;
      if (!this.businessCode) {
        this.$message("请输入业务编码");
        return;
      }
      this.ruleItems = [];
      let postData = {
        //业务编码
        businessCode: this.businessCode,
        transportTaskId: transportTaskId,
        dictTypeCodes: [
          "transport_car_type",
          "transport_car_use",
          "transport_car_task_status",
        ],
        userRoleCodes: ["transport_task_driver_user", "transport_task_porter"],
        serviceItemTypeCode: "use_in_transport_task", //随车物品服务基础信息加载，服务分类编码为[use_in_transport_task]，对应独立接口【/service-item/load-service-item-with-type-code】
      };
      Type["loadtransporttaskall"](postData)
        .then((response) => {
          let result = response;
          const {data} = result;
          if (!data) {
            this_load.$message("加载信息出错.");
          }

          //数据读取成功
          if (data.transportTask) {
            this_load.taskallInfo.transportTask = JSON.parse(
              JSON.stringify(data.transportTask)
            );
            //原车辆主键
            this_load.OldCarId =
              this_load.taskallInfo.transportTask.transportCarId;
          }
          if (data.dicts) {
            this_load.taskallInfo.dicts = JSON.parse(
              JSON.stringify(data.dicts)
            );
            //载入字典
            this_load.dicts = JSON.parse(JSON.stringify(data.dicts));
          }
          if (data.users) {
            this_load.taskallInfo.users = JSON.parse(
              JSON.stringify(data.users)
            );
          }
          if (data.serviceItems) {
            this_load.taskallInfo.serviceItems = JSON.parse(
              JSON.stringify(data.serviceItems)
            );
          }
          //家属姓名
          //家属联系方式
          if (data.funeralData) {
            //接运联系人
            this_load.taskallInfo.transportTask.transportLinkman =
              data.funeralData.transportLinkman;
            //接运联系人联系方式
            this_load.taskallInfo.transportTask.transportTelephone =
              data.funeralData.transportTelephone;
          }
          if (
            this_load.taskallInfo.serviceItems.use_in_transport_task.length > 0
          ) {
            this_load.taskallInfo.serviceItems.use_in_transport_task.forEach(
              (item) => {
                item.discountCharge = 0; //优惠初始化
              }
            );
          }
          if (
            this_load.CarryAddFlag &&
            this_load.taskallInfo.transportTask.charges.goodsServices.length >
            0 &&
            this_load.taskallInfo.serviceItems.use_in_transport_task.length > 0
          ) {
            this_load.taskallInfo.transportTask.charges.goodsServices.forEach(
              (n) => {
                //获取已追加项目名称
                this_load.taskallInfo.serviceItems.use_in_transport_task.forEach(
                  (list) => {
                    if (n.serviceItemId == list.id) {
                      this_load.$nextTick(() => {
                        n.itemName = list.itemName;
                        // this.$set(n,n.itemname,list.itemName)
                      });
                    }
                  }
                );
              }
            );
          }
          this.taskallInfo.transportTask.businessCode = this.businessCode;
          this_load.ruleItems = [];
          //收费规则
          if (data.ruleItems) {
            this_load.ruleItems = data.ruleItems;
          }
          //车辆类型车型合并
          this.transportCarTypes = this.pushDataMethod(
            data.dicts.transport_car_type,
            this.taskallInfo.transportTask.transportCarTypeCode,
            this.taskallInfo.transportTask.transportCarType
          );
          //车辆类型车型合并
          this.cars = [
            {
              id: this.taskallInfo.transportTask.transportCarId,
              carNo: this.taskallInfo.transportTask.transportCarNo,
            },
          ];
          //接运司机名称合并
          this.driverUsers = this.pushDriverMethod(
            data.users.transport_task_driver_user,
            this.taskallInfo.transportTask.driverUserId,
            this.taskallInfo.transportTask.driverUserName
          );
          //合并抬尸工数据集合

          this.transportTaskPorters = this.pushPorterDataArray(
            data.users.transport_task_porter,
            this.taskallInfo.transportTask.transportTaskPorterList
          );
          //车辆用途
          this.transportPurposes = this.pushDataMethod(
            data.dicts.transport_car_use,
            this.taskallInfo.transportTask.transportPurposeCode,
            this.taskallInfo.transportTask.transportPurpose
          );
          //接运状态名称
          this.processStates = this.pushDataMethod(
            data.dicts.transport_car_task_status,
            this.taskallInfo.transportTask.processStateCode,
            this.taskallInfo.transportTask.processState
          );

          //合并抬尸工数据集合

          this.DialogAddCarry = true;
        })
        .catch((error) => {
          this.$message(error);
        });
    },
    //加载冷藏任务所有数据
    loadColdStorageInfoall(Id) {
      if (!this.businessCode) {
        this.$message("请输入业务编码");
        return;
      }
      this.ruleItems = [];
      let this_load = this;
      let postData = {
        //业务编码
        businessCode: this.businessCode,
        coldStorageId: Id,
        dictTypeCodes: ["equipment_type", "refrigerated_state"],
        serviceItemTypeCode: "use_in_cold_storage",
      };
      //冷藏洽谈  页面权限验证及数据集中加载
      Type["loadcoldstorageall"](postData)
        .then((response) => {
          let result = response;
          const {data} = result;
          if (!data) {
            this.$message("加载信息出错.");
          }
          //数据读取成功
          if (data.coldStorage) {
            this.ColdStorageInfo.coldStorage = JSON.parse(
              JSON.stringify(data.coldStorage)
            );
            this.ProcessStateCodeOld = this.ColdStorageInfo.coldStorage.processStateCode;
          }
          if (data.dicts) {
            this.ColdStorageInfo.dicts = JSON.parse(JSON.stringify(data.dicts));
          }
          if (data.serviceItems) {
            this.ColdStorageInfo.serviceItems = JSON.parse(
              JSON.stringify(data.serviceItems)
            );
          }
          //逝者信息
          if (data.funeralDead) {
            this_load.funeralDead = data.funeralDead;
          }
          if (
            this.ColdStorageInfo.serviceItems.use_in_cold_storage.length > 0
          ) {
            this.ColdStorageInfo.serviceItems.use_in_cold_storage.forEach(
              (item) => {
                item.discountCharge = 0; //优惠初始化
              }
            );
          }
          if (
            this.ColdStorageAddFlag &&
            this.ColdStorageInfo.coldStorage.charges.goodsServices.length > 0 &&
            this.ColdStorageInfo.serviceItems.use_in_cold_storage.length > 0
          ) {
            this.ColdStorageInfo.coldStorage.charges.goodsServices.forEach(
              (n) => {
                //获取已追加项目名称
                this.ColdStorageInfo.serviceItems.use_in_cold_storage.forEach(
                  (list) => {
                    if (n.serviceItemId == list.id) {
                      this.$nextTick(() => {
                        n.itemName = list.itemName;
                      });
                    }
                  }
                );
              }
            );
          }
          this.ColdStorageInfo.coldStorage.businessCode = this.businessCode;
          //规则收费
          this.ruleItems = [];
          if (data.ruleItems) {
            this.ruleItems = data.ruleItems;
            //加载已删除的冷藏名称
            let exist = false;
            for (let k = 0; k < data.ruleItems.length; k++) {
              let ruleItem = data.ruleItems[k];
              if (
                ruleItem &&
                ruleItem.dataCode &&
                ruleItem.dataCode ==
                this.ColdStorageInfo.coldStorage.equipmentTypeCode
              ) {
                exist = true;
                break;
              }
            }
            //如果不存在
            let coldTextVal = this.ColdStorageInfo.coldStorage.equipmentType;
            let dataCodeVal = this.ColdStorageInfo.coldStorage
              .equipmentTypeCode;
            //判断不存百且非空，可以保存
            if (
              !exist &&
              !this.IsEmpty(coldTextVal) &&
              !this.isEmpty(dataCodeVal)
            ) {
              let ruleItemDisabled = {
                dataText: coldTextVal,
                dataCode: dataCodeVal,
                disableState: 1,
              };
              this.ruleItems.push(ruleItemDisabled);
            }

            //end
          }

          //冷藏状态流程
          this.processStates = data.dicts.refrigerated_state;
          //状态流程开始
          this.processStates = this.pushDataMethod(
            this.processStates,
            this.ColdStorageInfo.coldStorage.processStateCode,
            this.ColdStorageInfo.coldStorage.processState
          );
          //状态流程结束
          this.DialogColdStorage = true;
        })
        .catch((error) => {
          this.$message(error);
        });
    }, //判断是否为空
    IsEmpty(val) {
      if (val != null && val != "") {
        return false;
      } else {
        return true;
      }
    },
    //合并通过字典code及名称
    pushDriverMethod(data, idval, fullNameValue) {
      //判断data及code及名称不能为空
      if (
        data != null &&
        !this.IsEmpty(idval) &&
        !this.IsEmpty(fullNameValue) &&
        data.length > 0
      ) {
        let exist = false;
        for (let k = 0; k < data.length; k++) {
          let item = data[k];
          if (item && item.id && item.id == idval) {
            exist = true;
            break;
          }
        }
        //如果不存在
        if (!exist) {
          let itemDisabled = {
            fullName: fullNameValue,
            id: idval,
            disableState: 1,
          };
          data.push(itemDisabled);
        }
      }
      return data;
    },
    //合并通过字典code及名称
    pushDataMethod(data, code, text) {
      //判断data及code及名称不能为空
      if (
        data != null &&
        !this.IsEmpty(code) &&
        !this.IsEmpty(text) &&
        data.length > 0
      ) {
        let exist = false;
        for (let k = 0; k < data.length; k++) {
          let item = data[k];
          if (item && item.dataCode && item.dataCode == code) {
            exist = true;
            break;
          }
        }
        //如果不存在
        if (!exist) {
          let itemDisabled = {
            dataText: text,
            dataCode: code,
            disableState: 1,
          };
          data.push(itemDisabled);
        }
      }
      return data;
    }, //查询对象id是否在数据集合中
    getItemFlagById(data, item) {
      let flag = false;
      if (data && data.length > 0) {
        for (let i = 0; i < data.length; i++) {
          if (data[i].id == item.id) {
            flag = true;
            break;
          }
        }
      }
      //返回结果
      return flag;
    },
    //合并抬尸工，data为字典数据，dataOld为记录加载过来的数据
    pushPorterDataArray(data, dataOld) {
      //判断data及code及名称不能为空
      if (
        data != null &&
        dataOld != null &&
        data.length > 0 &&
        dataOld.length > 0
      ) {
        //定义新数据数组
        let addArray = [];
        for (let m = 0; m < dataOld.length; m++) {
          //获得旧数据的明细
          let itemOld = dataOld[m];
          if (
            itemOld != null &&
            itemOld.id != null &&
            itemOld.fullName != null
          ) {
            let flag_item = this.getItemFlagById(data, itemOld);
            //如果不存在
            if (!flag_item) {
              let itemDisabled = {
                id: itemOld.id,
                fullName: itemOld.fullName,
                disableState: 1,
              };
              addArray.push(itemDisabled);
            }
          }
        }

        //如果有新数据项，合并新数据项
        if (addArray && addArray.length > 0) {
          for (let i = 0; i < addArray.length; i++) {
            data.push(addArray[i]);
          }
        }
      }
      //返回合并后的新数据项
      return data;
    },
    //冷藏
    AddColdStorage() {
      let this_add = this;
      this_add.ColdStorageInfo.coldStorage = {
        id: 0,
        businessCode: "",
        equipmentTypeCode: "",
        equipmentId: "",
        processStateCode: 0,
        appointmentInTime: Date(),
        appointmentOutTime: "",
        version: 0,
        calculateRule: "",
        charges: {
          businessCharge: {
            id: 0,
            serviceItemId: 0,
            itemPrice: 0,
            itemNumber: 0,
            itemUnit: "",
            itemCharge: 0,
            discountCharge: 0,
            realityCharge: 0,
            asSettled: 0,
            version: 0,
          },
          goodsServices: [],
        },
      };
      this_add.loadColdStorageInfoall(0);
      this_add.ColdStorageAddFlag = true; //新增
    }, //验证冷藏信息
    checkCold() {
      if (!this.businessCode) {
        this.$message("请输入业务编码");
        return;
      }
      let this_check = this;
      let code = this_check.businessCode;
      let postData = {
        businessCode: code,
      };
      Type["loadservicenegotiationwithbusinesscode"](postData)
        .then((response) => {
          const {data} = response;
          if (!data) {
            this_check.$message("数据验证失败");
            return;
          }
          let coldFlag = true;
          //冷藏任务
          if (
            data &&
            data.coldStorageTasks &&
            data.coldStorageTasks.length >= 0
          ) {
            for (let i = 0; i < data.coldStorageTasks.length; i++) {
              let taskItem = data.coldStorageTasks[i];
              //冷藏0：已预订，1：未入藏，2：已入藏，4已临时性出仓不允许再增加新记录
              //未入藏，不能新增冷藏
              if (
                taskItem.processStateCode === 0
                || taskItem.processStateCode === 1
                || taskItem.processStateCode === 2
                || taskItem.processStateCode === 4
              ) {
                coldFlag = false;
                break;
              }
            }
            if (!coldFlag) {
              this_check.$message(
                "【已预订】或【未入藏】或【已入藏】或【临时出藏】信息只能添加一条"
              );
              return;
            } else {
              //验证通过，开始火化预约
              this_check.AddColdStorage();
            }
          } else {
            //验证通过，开始火化预约
            this_check.AddColdStorage();
          }
        })
        .catch((error) => {
          this_check.$message(error);
        });
    },
    //点击编辑
    ColdStorageInfoEdit(item) {
      this.ColdStorageAddFlag = false;
      this.loadColdStorageInfoall(item.id);
    },
    //点击删除接运任务
    ColdStoragedeleteRow(item) {
      this.$confirm("删除信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //点击确定的操作(调用接口)
          let postData = {
            id: item.id,
            version: item.version,
          };
          Type["deletecoldstoragewithid"](postData)
            .then((response) => {
              let result = response;
              const {message} = result;
              this.$message(message);
              this.searchData(this.businessCode);
            })
            .catch((error) => {
              this.$message(error);
            });
        })
        .catch(() => {
          //几点取消的提示
        });
    },

    //追加守灵厅
    AddWakeUp() {
      (this.WakeUpInfo.wakeMourn = {
        id: 0,
        businessCode: "",
        businessType: "",
        hallTypeCode: "", //礼厅类型编码
        hallId: 0,
        processStateCode: 0,
        appointmentInTime: "",
        appointmentOutTime: "",
        version: 0,
        calculateRule: "",
        charges: {
          businessCharge: {
            id: 0,
            serviceItemId: 0,
            itemPrice: 0,
            itemNumber: 0,
            itemUnit: "",
            itemCharge: 0,
            discountCharge: 0,
            realityCharge: 0,
            asSettled: 0,
            version: 0,
          },
          goodsServices: [],
        },
      }),
        //新增 ，新增守灵id为0，新增
        this.loadWakeMournAll(0);
      this.WakeUpAddFlag = true;
    }, //修改守灵厅信息
    WakeUpEdit(item) {
      // this.DialogWakeUp = false;
      this.WakeUpAddFlag = false;
      //修改守灵id为实际的值
      this.loadWakeMournAll(item.id);
    }, //删除礼厅的数据
    WakeUpdeleteRow(item) {
      this.$confirm("删除信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //点击确定的操作(调用接口)
          let postData = {
            id: item.id,
            version: item.version,
          };
          mournService["deleteWakeMournWithId"](postData)
            .then((response) => {
              let result = response;
              const {message} = result;
              this.$message(message);
              this.searchData(this.businessCode);
            })
            .catch((error) => {
              this.$message(error);
            });
        })
        .catch(() => {
          //几点取消的提示
        });
    },
    //守灵厅加载礼厅数据
    loadWakeMournAll(Id) {
      if (!this.businessCode) {
        this.$message("请输入业务编码");
        return;
      }
      this.ruleItems = [];
      let postData = {
        //业务编码
        businessCode: this.businessCode,
        mournCeremonyId: Id,
        businessType: "wake_mourn_type", //守灵类型wake_mourn_type;告别厅类型farewell_mourn_type
        dictTypeCodes: ["hall_business_type", "hall_status"],
        serviceItemTypeCode: "use_in_mourn_ceremony",
      };
      mournService["loadWakeMournAll"](postData)
        .then((response) => {
          let result = response;
          const {data} = result;
          if (!data) {
            this.$message("加载信息出错.");
          }
          //数据读取成功
          if (data.wakeMourn) {
            this.WakeUpInfo.wakeMourn = JSON.parse(
              JSON.stringify(data.wakeMourn)
            );
          }
          if (data.dicts) {
            this.WakeUpInfo.dicts = JSON.parse(JSON.stringify(data.dicts));
          }
          if (data.serviceItems) {
            this.WakeUpInfo.serviceItems = JSON.parse(
              JSON.stringify(data.serviceItems)
            );
          } //礼厅状态
          if (data.dicts.hall_status) {
            this.hallStatus = JSON.parse(
              JSON.stringify(data.dicts.hall_status)
            );
            //状态流程开始
            this.hallStatus = this.pushDataMethod(
              this.hallStatus,
              this.WakeUpInfo.wakeMourn.processStateCode,
              this.WakeUpInfo.wakeMourn.processState
            );
          }
          if (this.WakeUpInfo.serviceItems.use_in_mourn_ceremony.length > 0) {
            this.WakeUpInfo.serviceItems.use_in_mourn_ceremony.forEach(
              (item) => {
                item.discountCharge = 0; //优惠初始化
              }
            );
          }
          // console.log(this.WakeUpInfo.serviceItems)
          this.WakeUpInfo.wakeMourn.businessCode = this.businessCode;
          //传礼厅类型
          this.ruleItems = [];

          if (data.ruleItems) {
            this.ruleItems = data.ruleItems;
            //查询是否有删除的老数据
            let exist = false;
            for (let k = 0; k < data.ruleItems.length; k++) {
              let ruleItem = data.ruleItems[k];
              if (
                ruleItem != null &&
                !this.IsEmpty(ruleItem.dataCode) &&
                ruleItem.dataCode == this.WakeUpInfo.wakeMourn.hallTypeCode
              ) {
                exist = true;
                break;
              }
            }
            //如果不存在
            let hallTypeVal = this.WakeUpInfo.wakeMourn.hallType;
            let dataCodeVal = this.WakeUpInfo.wakeMourn.hallTypeCode;
            if (
              !exist &&
              !this.IsEmpty(hallTypeVal) &&
              !this.IsEmpty(dataCodeVal)
            ) {
              let ruleItemDisabled = {
                dataText: hallTypeVal,
                dataCode: dataCodeVal,
                disableState: 1,
              };
              this.ruleItems.push(ruleItemDisabled);
            }
          }
          //旧状态赋值
          this.ProcessStateWakeUpOld = this.WakeUpInfo.wakeMourn.processStateCode;

          this.DialogWakeUp = true;
        })
        .catch((error) => {
          this.$message(error);
        });
    },
    /** 守灵厅结束**/
    /***告别厅***/
    //追加告别厅
    AddFareWell() {
      this.FareWellInfo.farewellMourn = {
        id: 0,
        businessCode: "",
        businessType: "",
        hallTypeCode: "", //礼厅类型编码
        hallId: 0,
        processStateCode: 0,
        appointmentInTime: "",
        appointmentOutTime: "",
        version: 0,
        calculateRule: "",
        charges: {
          businessCharge: {
            id: 0,
            serviceItemId: 0,
            itemPrice: 0,
            itemNumber: 0,
            itemUnit: "",
            itemCharge: 0,
            discountCharge: 0,
            realityCharge: 0,
            asSettled: 0,
            version: 0,
          },
          goodsServices: [],
        },
      };
      this.FareWellLoadFarewellMournAll(0);
      this.FareWellAddFlag = true;
    },
    FareWellEdit(item) {
      this.FareWellAddFlag = false;
      this.FareWellLoadFarewellMournAll(item.id);
    },
    FareWelldeleteRow(item) {
      this.$confirm("删除信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //点击确定的操作(调用接口)
          let postData = {
            id: item.id,
            version: item.version,
          };
          mournService["deleteFarewellMournWithId"](postData)
            .then((response) => {
              let result = response;
              const {message} = result;
              this.$message(message);
              this.searchData(this.businessCode);
            })
            .catch((error) => {
              this.$message(error);
            });
        })
        .catch(() => {
          //几点取消的提示
        });
    }, //存入类型新规则
    //存入类型新规则
    pushRuleItems(data, code, text) {
      if (data && data.length > 0 && code && text) {
        let exist = false;
        for (let k = 0; k < data.length; k++) {
          let ruleItem = data[k];
          if (ruleItem && ruleItem.dataCode && ruleItem.dataCode == code) {
            exist = true;
            break;
          }
        }

        //如果不存在

        if (!exist && !this.IsEmpty(code) && !this.IsEmpty(text)) {
          let itemDisabled = {
            dataText: text,
            dataCode: code,
            disableState: 1,
          };
          data.push(itemDisabled);
        }
      }
      return data;
    }, //合并火化炉类型
    pushRuleItemsMini(data) {
      let newData = new Array();
      if (data && data.length > 0) {
        for (let k = 0; k < data.length; k++) {
          let ruleItem = data[k];
          let flag = this.IsExist(
            newData,
            ruleItem.dataCode,
            ruleItem.dataText
          );
          if (
            !flag &&
            !this.IsEmpty(ruleItem.dataCode) &&
            !this.IsEmpty(ruleItem.dataText)
          ) {
            let item = {
              dataText: ruleItem.dataText,
              dataCode: ruleItem.dataCode,
              disableState: ruleItem.disableState,
            };
            newData.push(item);
          }
        }
      }
      return newData;
    },
    IsExist(itemData, code, text) {
      let flag = false;
      if (itemData && itemData.length > 0) {
        for (let m = 0; m < itemData.length; m++) {
          if (itemData[m].dataText == text && itemData[m].dataCode == code) {
            flag = true;
            break;
          }
        }
      }
      return flag;
    },
    //加载告别礼厅数据
    FareWellLoadFarewellMournAll(Id) {
      if (!this.businessCode) {
        this.$message("请输入业务编码");
        return;
      }
      //定义参数
      let postData = {
        //业务编码
        businessCode: this.businessCode,
        businessType: "farewell_mourn_type", //守灵类型wake_mourn_type;告别厅类型farewell_mourn_type
        mournCeremonyId: Id,
        dictTypeCodes: ["hall_business_type", "hall_status"],
        serviceItemTypeCode: "use_in_mourn_ceremony",
      };
      //查询基础数据
      mournService["loadFarewellMournAll"](postData)
        .then((response) => {
          let result = response;
          const {data} = result;
          if (!data) {
            this.$message("加载信息出错.");
          }
          //数据读取成功
          if (data.farewellMourn) {
            this.FareWellInfo.farewellMourn = JSON.parse(
              JSON.stringify(data.farewellMourn)
            );
          }
          if (data.dicts) {
            this.FareWellInfo.dicts = JSON.parse(JSON.stringify(data.dicts));
          }
          //礼厅状态
          if (data.dicts.hall_status) {
            this.hallStatus = JSON.parse(
              JSON.stringify(data.dicts.hall_status)
            );
            //状态流程开始
            this.hallStatus = this.pushDataMethod(
              this.hallStatus,
              this.FareWellInfo.farewellMourn.processStateCode,
              this.FareWellInfo.farewellMourn.processState
            );
          }
          if (data.serviceItems) {
            this.FareWellInfo.serviceItems = JSON.parse(
              JSON.stringify(data.serviceItems)
            );
          }
          if (this.FareWellInfo.serviceItems.use_in_mourn_ceremony.length > 0) {
            this.FareWellInfo.serviceItems.use_in_mourn_ceremony.forEach(
              (item) => {
                item.discountCharge = 0; //优惠初始化
              }
            );
          }
          this.FareWellInfo.farewellMourn.businessCode = this.businessCode;
          //传礼厅类型
          this.ruleItems = [];
          let codeVal = this.FareWellInfo.farewellMourn.hallTypeCode;
          let textVal = this.FareWellInfo.farewellMourn.hallType;
          this.ruleItems = data.ruleItems;
          if (
            data.ruleItems &&
            !this.IsEmpty(codeVal) &&
            !this.IsEmpty(textVal)
          ) {
            //合并礼厅类型
            this.ruleItems = this.pushRuleItems(
              this.ruleItems,
              codeVal,
              textVal
            );
          }
          console.log(this.ruleItems);
          this.ProcessStateFareWellOld = this.FareWellInfo.farewellMourn.processStateCode;
          this.DialogFareWell = true;
        })
        .catch((error) => {
          this.$message(error);
        });
    },
    /***告别厅***/

    /** 火化任务开始**/
    //预约火化
    AddFire() {
      let this_add = this;
      this_add.FireInfo.cremation = {
        id: 0,
        businessCode: "",
        furnaceTypeCode: 43,
        cremationChargeTypeCode: 0,
        furnaceId: "",
        asAppointment: 0,
        appointmentStartTime: "",
        appointmentFinishTime: "",
        cremationNo: "",
        randomCode: "",
        ashHandleTypeCode: 2,
        ashWhereaboutsCode: "",
        version: 0,
        charges: {
          businessCharge: {
            id: 0,
            serviceItemId: 0,
            itemPrice: 0,
            itemNumber: 0,
            itemUnit: "",
            itemCharge: 0,
            discountCharge: 0,
            realityCharge: 0,
            asSettled: 0,
            version: 0,
          },
          goodsServices: [],
        },
      };
      this_add.loadcremationall(0);
      this_add.FireInfo.cremation.appointmentDate = new Date();
      this_add.FireAddFlag = true;
    }, //验证火化信息
    checkFrie() {
      if (!this.businessCode) {
        this.$message("请输入业务编码");
        return;
      }
      let this_check = this;
      let code = this_check.businessCode;
      let postData = {
        businessCode: code,
      };
      Type["loadservicenegotiationwithbusinesscode"](postData)
        .then((response) => {
          const {data} = response;
          if (!data) {
            this_check.$message("数据验证失败");
            return;
          }
          //火化任务
          if (data && data.cremationTasks && data.cremationTasks.length >= 1) {
            this_check.$message("火化信息只能添加一条");
          } else {
            //验证通过，开始火化预约
            this_check.AddFire();
          }
        })
        .catch((error) => {
          this_check.$message(error);
        });
    },
    FireEdit(item) {
      this.loadcremationall(item.id);
      this.FireAddFlag = false;
    },
    FiredeleteRow(item) {
      this.$confirm("删除信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //点击确定的操作(调用接口)
          let postData = {
            id: item.id,
            version: item.version,
          };
          Type["deletecremationwithid"](postData)
            .then((response) => {
              let result = response;
              const {message} = result;
              this.$message(message);
              this.searchData(this.businessCode);
            })
            .catch((error) => {
              this.$message(error);
            });
        })
        .catch(() => {
          //几点取消的提示
        });
    },
    //通过id载入火化任务
    loadcremationall(Id) {
      if (!this.businessCode) {
        this.$message("请输入业务编码");
        return;
      }
      let postData = {
        //业务编码
        businessCode: this.businessCode,
        cremationId: Id,
        dictTypeCodes: [
          "furnace_type",
          "ashes_treatment",
          "ashes_whereabouts",
          "cremation_type",
          "cremation_charge_type",
        ],
        serviceItemTypeCode: "use_in_cremation",
      };
      this.ruleItems = [];
      Type["loadcremationall"](postData)
        .then((response) => {
          let result = response;
          const {data} = result;
          //console.log("rule1:" + JSON.stringify(data.ruleItems));
          if (!data) {
            this.$message("加载信息出错.");
          }

          //数据读取成功
          if (data.cremation) {
            this.FireInfo.cremation = JSON.parse(
              JSON.stringify(data.cremation)
            );
          }
          if (data.dicts) {
            this.FireInfo.dicts = JSON.parse(JSON.stringify(data.dicts));
          }
          if (data.serviceItems) {
            this.FireInfo.serviceItems = JSON.parse(
              JSON.stringify(data.serviceItems)
            );
          }
          // //载入火化计费类型
          // if (data.funeralDead && data.funeralDead.cremationChargeTypeCode) {
          //   this.FireInfo.cremation.cremationChargeTypeCode =
          //     data.funeralDead.cremationChargeTypeCode;
          // }
          if (this.FireInfo.serviceItems.use_in_cremation.length > 0) {
            this.FireInfo.serviceItems.use_in_cremation.forEach((item) => {
              item.discountCharge = 0; //优惠初始化
            });
          }
          //火化炉类型
          this.ruleItems = [];

          if (data.ruleItems) {
            this.ruleItems = data.ruleItems;
            let code = this.FireInfo.cremation.furnaceTypeCode;
            let text = this.FireInfo.cremation.furnaceType;
            //合并火化炉类型
            this.ruleItems = this.pushRuleItems(this.ruleItems, code, text);
            //合并火化炉类型
            this.ruleItemsMini = this.pushRuleItemsMini(this.ruleItems);
          }
          //火化类型funeralDead
          this.cremationTypes = this.FireInfo.dicts.cremation_type;
          //合并后的值
          this.cremationTypes = this.pushRuleItems(
            this.cremationTypes,
            data.funeralDead.cremationTypeCode,
            data.funeralDead.cremationType
          );
          //火化计费类型
          this.cremationChargeTypes = this.FireInfo.dicts.cremation_charge_type;
          //骨灰处理方式合并后的值
          this.ashHandleTypes = this.pushRuleItems(
            this.FireInfo.dicts.ashes_treatment,
            this.FireInfo.cremation.ashHandleTypeCode,
            this.FireInfo.cremation.ashHandleType
          );
          //骨灰去向合并后的值
          this.ashWhereabouts = this.pushRuleItems(
            this.FireInfo.dicts.ashes_whereabouts,
            this.FireInfo.cremation.ashWhereaboutsCode,
            this.FireInfo.cremation.ashWhereabouts
          );
          if (this.FireInfo.cremation.ashWhereaboutsCode == "" && this.FireInfo.cremation.ashWhereaboutsCode.length == 0) {

            this.FireInfo.cremation.ashWhereaboutsCode = this.getDefault(this.ashWhereabouts);
          }


          this.FireInfo.cremation.businessCode = this.businessCode;
          this.DialogFire = true;
        })
        .catch((error) => {
          this.$message(error);
        });
    },
    getDefault(data) {
      console.log("test:" + data);
      let item = null;
      let readValue = "";
      if (data && data.length > 0) {
        for (let i = 0; i < data.length; i++) {
          item = data[i];
          if (1 == item.asDefault) {
            readValue = item.dataCode;
            break;
          }
        }
      }
      return readValue;
    },
    /** 火化任务结束**/

    /******新增殡仪服务开始******/
    addService() {
      this.loadserviceitemwithtypecode("type_of_funeral_supplies").then(
        (data) => {
          // this.GoodsServiceItems.businessCode = this.businessCode
          this.DialogGoodsService = true;
          this.DialogGoodsServiceTitleName = "殡仪服务";
          this.GoodsServiceItems = [];
          //遍历获得殡仪服务  0，服务；1，物品
          for (let i = 0; i < data.length; i++) {
            let serviceItem = data[i]
            //当字段=0 说明是殡仪服务 进行添加
            if (serviceItem.asGoods === 0) {
              this.GoodsServiceItems.push(serviceItem);
            }
          }
        }
      );
    },
    /******新增丧葬用品  开始******/
    addGoods() {
      this.loadserviceitemwithtypecode("type_of_funeral_supplies").then(
        (data) => {
          // this.GoodsServiceItems.businessCode = this.businessCode
          this.DialogGoodsService = true;
          this.DialogGoodsServiceTitleName = "丧葬用品";
          this.GoodsServiceItems = [];
          //遍历获得丧葬用品  0，服务；1，物品
          for (let i = 0; i < data.length; i++) {
            let serviceItem = data[i]
            //当字段=1 说明是丧葬用品 进行添加
            if (serviceItem.asGoods === 1) {
              this.GoodsServiceItems.push(serviceItem);
            }
          }
        }
      );
    },
    loadserviceitemwithtypecode(typeCode) {
      if (!this.businessCode) {
        this.$message("请输入业务编码");
        return;
      }
      let postData = {
        typeCode: typeCode,
      };
      return new Promise((resolve, reject) => {
        Type["loadserviceitemwithtypecode"](postData)
          .then((response) => {
            let result = response;
            const {data} = result;
            if (data.length > 0) {
              data.forEach((item) => {
                item.discountCharge = 0;
                item.realityCharge = 0;
                item.asSettled = "未结算";
                item.version = 0;
              });
              resolve(data);
            }
          })
          .catch((error) => {
            this.$message(error);
            reject(error);
          });
      });
    },
    GoodsServicedeleteRow(id, version) {
      this.$confirm("删除信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //点击确定的操作(调用接口)
          let postData = {
            id: id,
            version: version,
          };
          console.log(postData, "服務物品刪除請求數據")
          Type["deletefuneralsupplieswithid"](postData)
            .then((response) => {
              let result = response;
              const {message} = result;
              this.$message(message);
              this.searchData(this.businessCode);
            })
            .catch((error) => {
              this.$message(error);
            });
        })
        .catch(() => {
          //几点取消的提示
        });
    },
    /******新增丧葬用品及服务   结束******/

    /******整容  开始******/
    //追加整容
    AddFace() {
      let loadFaceData = this.loadserviceitemwithtypecode("type_of_face_lift");
      let this_face = this;
      if (loadFaceData) {
        loadFaceData.then((data) => {
          if (data) {
            // this.FaceItems.businessCode = this.businessCode
            this_face.FaceItems = data;
            this_face.DialogFace = true;
          }
        });
      }
    },
    FacedeleteRow(item) {
      this.$confirm("删除信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          //点击确定的操作(调用接口)
          let postData = {
            id: item.id,
            version: item.version,
          };
          //删除整容id
          Type["deletefaceliftwithid"](postData)
            .then((response) => {
              let result = response;
              const {message} = result;
              this.$message(message);
              this.searchData(this.businessCode);
            })
            .catch((error) => {
              this.$message(error);
            });
        })
        .catch(() => {
          //几点取消的提示
        });
    },
    /******整容   结束******/

    //费用结算
    TotalMoney() {
      this.$router.push({path: '/costSettlement'});
    },
    //直接付款
    NowPay() {
      if (!this.businessCode) {
        this.$message("业务编码不能为空");
        return;
      }
      /*不可解结算判断标志 0可结算，1不可结算*/
      let UnsettledFlag = 0;
      this.Unsettled = [];
      console.log(this.ruleFormCalc);
      const arr = [
        "transportTasks",
        "coldStorageTasks",
        "wakeMournTasks",
        "farewellMournTasks",
        "cremationTasks",
      ];
      const arr2 = ["faceLiftTasks"];
      const arr3 = ["funeralSuppliesTasks"];
      for (let i = 0; i < arr.length; i++) {
        if (
          !UnsettledFlag &&
          this.ruleFormCalc[arr[i]] &&
          this.ruleFormCalc[arr[i]].length > 0
        ) {
          this.ruleFormCalc[arr[i]].forEach((item) => {
            if (
              !UnsettledFlag &&
              item.charges &&
              item.charges.goodsServices.length > 0
            ) {
              item.charges.goodsServices.forEach((n) => {
                if (n.asUnsettled && n.asUnsettled == 1) {
                  UnsettledFlag = 1;
                  this.$message("存在不可结算费用，不能直接付款");
                  return;
                }
                if (n.asSettled == 0) {
                  //未结算
                  this.Unsettled.push(n);
                }
              });
            }
          });
        }
      }
      for (let k = 0; k < arr2.length; k++) {
        if (
          this.ruleFormCalc[arr2[k]] &&
          this.ruleFormCalc[arr2[k]].length > 0
        ) {
          this.ruleFormCalc[arr2[k]].forEach((n) => {
            if (n.asSettled == 0) {
              //未结算;
              //整容的费用id不是计费id需要从chargeId中获得
              n.id = n.chargeId;
              this.Unsettled.push(n);
            }
          });
        }
      }
      for (let j = 0; j < arr3.length; j++) {
        if (
          this.ruleFormCalc[arr3[j]] &&
          this.ruleFormCalc[arr3[j]].length > 0
        ) {
          this.ruleFormCalc[arr3[j]].forEach((m) => {
            if (m.asSettled == 0) {
              //未结算
              this.Unsettled.push(m);
            }
          });
        }
      }
      if (UnsettledFlag) {
        this.$message("存在不可结算费用，不能直接付款");
      } else if (this.businessCode && this.Unsettled.length > 0) {
        this.NowPayFlag = true;
      } else {
        this.$message("获取不到相应信息");
      }
    }, //打印服务协议单
    printServiceAgreement(printData) {
      console.log(printData, "打印服务协议单")
      let this_print = this;
      let LODOP = getLodop();
      if (LODOP == null || !LODOP) {
        this_print.$.messager.alert(
          "系统提示",
          "您的浏览器不支持打印控件，请用IE重试或安装打印控件后重试"
        );
        return;
      }

      for (let key in printData) {
        printData[key] = printData[key] ? printData[key] : "　";
      }

      let firstParty = "XX殡仪馆";
      //乙方，逝者家属
      let secondParty = printData.memberName;
      //家属联系手机
      let mobilePhone = printData.mobilePhone;
      //逝者姓名
      let deadName = printData.deadName;
      //逝者性别
      let deadGender = printData.deadGender;
      //逝者年龄
      let deadAge = printData.deadAge;
      //生前住址
      let beforeDeathAddress = printData.beforeDeathAddress;
      //服务收费项目itemName服务项目 itemCharge服务费用
      let chargeItemss = printData.faceLiftItems;
      let chargeItems = printData.gaobieItems;

      console.log(chargeItemss);
      //总费用
      //总减免费用
      let discountTotalCharge = printData.discountTotalCharge;
      let protect =
        "　　根据《中华人民共和国合同法》、《中华人民共和国消费者权益保护法》、《殡葬管理条例》及相关法律、\n" +
        "法规，结合本次殡仪服务的具体内容，甲、乙双方在平等、自愿、公平、诚实信用的基础上，经协商一致，达成\n" +
        "如下协议。<br/><br/>";

      let proHead = `
      <div style="padding-top:5px;">   甲方（家属、承办人）：${printData.memberName}      乙方：临沂市第二殡仪馆</div>
      <div>逝者姓名：${printData.deadName}   性别：${printData.deadGender}  年龄：${printData.deadAge}</div>
      <div>甲方与逝者关系：${printData.firstPartyRelation}   联系电话：${printData.mobilePhone}</div>
      <div>联系地址：${printData.memberAddress}</div>
      <div>注：甲方有责任及义务,对所提供的身份证、户口本,《居民死亡推断书》等证件真实有效。如果甲方提供的上述手续不真实,出现责任、纠纷等问题,甲方负全部责任。遗体 存放期间家属查看遗体时，必须出具甲方签订人有效证件。甲方签字人非逝者近亲属签订协议后，一日内将本协议内容告知逝者近亲属。</div>
      <div>注：收费收费依据为潍发改物价<2018>73号文件第二条规定</div>
     `;

      let listTableItem = "<tr>";
      if (chargeItems && chargeItems.length > 0) {
        for (let i = 0; i < chargeItems.length; i++) {
          listTableItem +=
            "<td>" +
            chargeItems[i].itemName +
            "</td><td>" +
            chargeItems[i].itemPrice +
            "</td><td>" +
            chargeItems[i].itemNumber +
            "</td><td>" +
            chargeItems[i].itemCharge +
            "</td>";
          if (i % 2 == 1 && i != 0 && i != chargeItems.length - 1) {
            listTableItem += "</tr>";
          }
          if (i == chargeItems.length - 1 && i % 2 != 1) {
            listTableItem += "<td></td><td></td><td></td><td></td>";
          }
        }
        listTableItem += "</tr>";
      }
      let listTableBottom =
        "<tr><td colspan='8'>总费用：" +
        printData.faceLiftItemTotalCharge +
        "大写：" +
        printData.faceLiftItemTotalChargeText +
        "</td></tr>";

      let listTableItems = "<tr>";
      if (chargeItemss && chargeItemss.length > 0) {
        for (let i = 0; i < chargeItemss.length; i++) {
          listTableItems +=
            "<td>" +
            chargeItemss[i].itemName +
            "</td><td>" +
            chargeItemss[i].itemPrice +
            "</td><td>" +
            chargeItemss[i].itemNumber +
            "</td><td>" +
            chargeItemss[i].itemCharge +
            "</td>";
          if (i % 2 == 1 && i != 0 && i != chargeItemss.length - 1) {
            listTableItems += "</tr>";
          }

          if (i == chargeItemss.length - 1 && i % 2 != 1) {
            listTableItems += "<td></td><td></td><td></td><td></td>";
          }
        }
        listTableItems += "</tr>";
      }
      let listTableBottoms =
        "<tr><td colspan='10'>总费用：" +
        printData.gaoBieItemTotalCharge +
        "大写：" +
        printData.gaoBieItemTotalChargeText +
        "</td></tr>";
      // let listJianMian = "<tr><td colspan='5'>";
      // if (discountChargeItems && discountChargeItems.length > 0) {
      //   for (let j = 0; j < discountChargeItems.length; j++) {
      //     listJianMian +=
      //       discountChargeItems[j].itemName +
      //       ":" +
      //       discountChargeItems[j].itemCharge;
      //   }
      //   listJianMian += "</td></tr>";
      // }
      let listRemark = "<tr><td colspan='5'>说明</td></tr>";
      let space = `&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`;
      let listTAble =
        "<table border='1' cellspacing='0' bordercolor='#000000' width = '100%' style='border-collapse:collapse;'><tr><td>服务项目</td><td>单价</td><td>数量</td><td>金额</td><td>服务项目</td><td>单价</td><td>数量</td><td>金额</td></tr>" +
        listTableItem +
        listTableBottom +
        // listJianMian +
        // listRemark +
        "</table>";

      let listTAbles =
        "<table border='1' cellspacing='0' bordercolor='#000000' width = '100%' style='border-collapse:collapse;'><tr><td>服务项目</td><td>单价</td><td>数量</td><td>金额</td><td>服务项目</td><td>单价</td><td>数量</td><td>金额</td></tr>" +
        listTableItems +
        listTableBottoms +
        "</table>";
      let arrayTitle = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十'];
      let countTitle = 0;
      let allHtml = "";
      allHtml += protect;
      allHtml += proHead;
      //      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTime}】起存放在殡仪馆${printData.coldEquipmentType}，因尸体腐败、异味、传染病等原因，每日加收90元，属于殡葬公益范围内的第一天普通冷藏减免80元。
      //客户定制需求，暂时不需要该条目显示
      /*if (printData.isCold == 1) {
        let one = `<h4> ` + arrayTitle[countTitle] + `、遗体冷藏服务及规定： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTime}】起存放在殡仪馆冷藏。
      <div>注： 因尸体腐败、异味、传染病等原因，每日加收90元 以此类推。</div>
      </div>
      <div>2.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>
      <div>3.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
`;
        countTitle++;
        allHtml += one;
      }*/
      if (printData.isJieDong === 1) {
        let two = `
      <h4> ` + arrayTitle[countTitle] + `、遗体解冻服务： </h4>
      <div>1.	应甲方要求，乙方提前将逝者遗体进行解冻，为确保遗体按时解冻及安全，存在于特定房间，收费【${printData.jieDongCharge}】元。
      <div>2.	甲方要求乙方帮助搬运遗体的，乙方将按规定另收取搬运费。</div>
      div>3.	化冻期间受个体差异因素的影响，可能会发生遗体变色发黑、变形渗血等不确定因素与化冻前可能有较大的差别，乙方均不承担责任。</div>
      `;
        countTitle++;
        allHtml += two;
      }

      if (printData.isDanJian === 1) {
        let three = `<h4> ` + arrayTitle[countTitle] + `、单间冷藏租用服务： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTimeDanJian}】起存放在殡仪馆单间冷藏柜(柜号：${printData.equipmentCodeDanJian})冷藏,价格由双方协商确定。
      </div>
      <div>2.	乙方应甲方要求，提供单间冷藏柜租用，甲方遵循乙方单间冷藏柜使用管理规定，严禁在室内使用明火，因甲方违反规定造成的后果甲方负责。  </div>
      <div>3.	乙方应配有消防器材且不定时查看，遇有违反规定的应及时制止，甲方应积极配合，自觉服从管理。</div>
      <div>4.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
      <div>5.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>

`;
        countTitle++;
        allHtml += three;
      }
      if (printData.isDanTi === 1) {
        let three = `<h4> ` + arrayTitle[countTitle] + `、恒温冷藏租用服务： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTimeDanTi}】起存放在殡仪馆恒温冷藏柜(柜号：${printData.equipmentCodeDanTi})冷藏,价格由双方协商确定。
      </div>
      <div>2.	乙方应甲方要求，提供恒温冷藏柜租用，甲方遵循乙方恒温冷藏柜使用管理规定，严禁在室内使用明火，因甲方违反规定造成的后果甲方负责。  </div>
      <div>3.	乙方应配有消防器材且不定时查看，遇有违反规定的应及时制止，甲方应积极配合，自觉服从管理。</div>
      <div>4.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
      <div>5.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>

`;
        countTitle++;
        allHtml += three;
      }
      if (printData.isShouLingEquipmentType === 1) {
        let three = `<h4> ` + arrayTitle[countTitle] + `、守灵室冷藏租用服务： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTimeShouLing}】起存放在殡仪馆守灵室冷藏柜(柜号：${printData.equipmentCodeShouLing})冷藏,价格由双方协商确定。
      </div>
      <div>2.	乙方应甲方要求，提供守灵室冷藏柜租用，甲方遵循乙方守灵室冷藏柜使用管理规定，严禁在室内使用明火，因甲方违反规定造成的后果甲方负责。  </div>
      <div>3.	乙方应配有消防器材且不定时查看，遇有违反规定的应及时制止，甲方应积极配合，自觉服从管理。</div>
      <div>4.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
      <div>5.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>

`;
        countTitle++;
        allHtml += three;
      }
      if (printData.isPuTongEquipmentType === 1) {
        let three = `<h4> ` + arrayTitle[countTitle] + `、普通冷藏柜租用服务： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTimePuTong}】起存放在殡仪馆普通冷藏柜(柜号：${printData.equipmentCodePuTong})冷藏,价格为80每天,不足12小时按半天计算。
      <div>注： 因尸体腐败、异味、传染病等原因，每日加收90元 以此类推。</div>
      </div>
      <div>2.	乙方应甲方要求，提供普通冷藏柜租用，甲方遵循乙方普通冷藏柜使用管理规定，严禁在室内使用明火，因甲方违反规定造成的后果甲方负责。  </div>
      <div>3.	乙方应配有消防器材且不定时查看，遇有违反规定的应及时制止，甲方应积极配合，自觉服从管理。</div>
      <div>4.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
      <div>5.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>

`;
        countTitle++;
        allHtml += three;
      }

      if (printData.isGaoBie === 1) {
        let four = `<h4> ` + arrayTitle[countTitle] + `、遗体告别仪式服务： </h4>
      <div>1、应甲方要求，乙方为甲方提供遗体告别仪式服务，甲方初步拟订告别时间后通知乙方，乙方根据告别情况具体安排，时间的最终确定由甲、乙双方商定；不能随意变更，确有特殊情况需调整时间的，必须事先通知乙方，征得同意后，方可调整，但不得影响已预订的其他告别。</div>
      <div>2、甲方确定【${printData.gaoBieTime}】为逝者${printData.deadName}在临沂市第二殡仪馆【${printData.gaoBieTing}】举行遗体告别仪式。</div>
      <div>3、告别前半小时，乙方可组织甲方人员，将逝者遗体搬运至告别厅，搬运前甲方要对遗体进行确认并签字。举行遗体告别仪式前，乙方负责组织参加告别的人员列队和亲属的站位，甲方有义务积极配合乙方。</div>
      <div>4、告别期间，因供电方停电或线路出现故障，造成音响、LED显示屏不能正常使用，乙方不承担责任，有义务积极联系排除故障，尽快恢复。告别中，乙方可指导亲属文明治丧，没有义务必须按当地习俗礼仪帮助主持丧事。</div>
`;
        countTitle++;
        allHtml += four;
        let five = `<h4> ` + arrayTitle[countTitle] + `、 租用告别厅和告别厅鲜花租用服务： </h4>
      <div>1、应甲方要求，乙方提前将告别厅将鲜花摆放装饰好。乙方原因无法提供鲜花服务时，
      应提前12小时通知甲方终止本协议。双方互不承担责任。甲方确定租用告别厅和告别厅内租用鲜花装饰，价格由双方协商确定。
      </div>
      <div>2.因鲜花受季节影响较大，具体造型、花色等以现场实物为准。鲜花及造型在使用过程中会发生细微的变色或变形，属鲜花使用过程中的正常现象。甲方应提醒随同人员不要随意变动造型和拿取鲜花。因甲方原因造成的鲜花造型改变和丢失，应甲方负责，乙方不承担责任。</div>
`;

        let seven = `<h4> ` + arrayTitle[countTitle] + `、遗体棺内装饰服务： </h4>
            <div>1 应甲方要求，乙方为甲方逝者提供鲜花装饰服务，价格由双方协商确定。</div>
            <div>费用明细：</div>
               ${listTAble}
               `;
        countTitle++;
        allHtml += seven;
      }

      if (printData.isSongLingService === 1) {

        let six = `<h4> ` + arrayTitle[countTitle] + `、送灵服务： </h4>
      <div>1、应甲方家属要求，乙方为甲方逝者${printData.deadName}提供遗体送灵服务，甲方初步拟订送灵时间后通知乙方，乙方根据实际情况具体安排，甲方遵从乙方人员安排，具体费用由乙方告知甲方，
      甲方同意后签订服务协议，商定时间<span style="text-decoration:underline">${space}${space}</span>       年<span style="text-decoration:underline">${space}</span>      月<span style="text-decoration:underline">${space}</span>      日<span style="text-decoration:underline">${space}</span>      时<span style="text-decoration:underline">${space}</span>     分。
      确有特殊情况需调整时间的，必须事先通知乙方，征得同意后方可调整。</div>`;
        countTitle++;
        allHtml += six;
      }

      if (printData.isFaceLift == 1) {

        let eight = `<h4> ` + arrayTitle[countTitle] + `、遗体整容服务： </h4>
                <div>1、应甲方要求，乙方为逝者提供整形、整容、刮脸、化妆、美容美发、净身、缝合、穿脱衣等服务。因遗体出现</br><span class='idSpan' style='width: 150px'></span>情况，价格由双方协商确定。由于人去世后面容会有较大的变化，整容期间受个体差异因素的影响，可能会发生遗体变色、变形、渗血、伤口开裂；整容后与生前可能仍有一定的差别，甲方应予以谅解；遗体整容前，甲方必须将遗体随身的贵重物取出另行保管，如发生遗失、损坏等上述情况，乙方均不承担责任。</div>
                <div>费用明细：</div>
               ${listTAbles}`;
        countTitle++;
        allHtml += eight;
      }
      if (printData.isShouLing == 1) {

        let nine = `<h4> arrayTitle[countTitle]` + `、守灵室冷藏服务： </h4>
                <div> 1、甲方自愿将逝者【${printData.deadName}】遗体由【${printData.shouLingBeginTime}】起
                存放在殡仪馆豪华冷藏守灵室。</div>

                <div> 2、遗体存放前，甲方必须将遗体随身的贵重物品取出。遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结冰、变色、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。
                <div>3、遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置随时通知甲方转存遗体。</div>


            `;
        countTitle++;
        allHtml += nine;
      }
      let last = ` <div>注：</div>
 <div>甲方必须提供本协议涉及的信息真实、准确，因信息不实造成的所有后果由甲方承担。遗体 存放期间家属查看遗体时，必须出具甲方签订人有效证件。甲方签字人非逝者近亲属签订协议后，一日内将本协议内容告知逝者近亲属。</div>
      <div>甲方：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;								乙方：临沂市第二殡仪馆</div>
       <div style="text-align:right">经办人：【${printData.userCode}】&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
      <div>时间：${dataFormate(new Date())}</div>
      <div>对以上服务是否满意：<span class='idSpan' style='width: 50px'>　</span>/div>
`;
      allHtml += last;

      let theTitle = "<p style='font-size:20px;font-weight: bold;width: 700px;height: 80px; text-align: center'>殡仪服务合同</p>";
      //纸张
      LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
      let recOperationcode = 234444;
      //设置字体
      LODOP.SET_PRINT_STYLE("FontSize", 11);
      //调用打印控件进行测试
      // LODOP.ADD_PRINT_BARCODE(39, 580, 50, 50, "QRCode", printData.businessCode);
      LODOP.ADD_PRINT_BARCODE("4mm", "160mm", "28mm", "28mm", "QRCode", printData.businessCode);
      LODOP.SET_PRINT_STYLEA(0, "QRCodeVersion", 2);
      LODOP.SET_PRINT_STYLEA(0, "DataCharset", "UTF-8");
      LODOP.ADD_PRINT_TEXT("27mm", "140mm", 300, 25, "业务编码：" + printData.businessCode);

      //LODOP.ADD_PRINT_HTM( 20, 260,300,1000, "<p style='font-size:20px;font-weight: bold;'>自愿选择性殡葬服务协议书</p>");

      //打印协议
      LODOP.ADD_PRINT_HTM(20, 50, 650, 1000, theTitle + allHtml);
      // LODOP.ADD_PRINT_HTM(180, 50, 650, 80, proHead);
      //LODOP.ADD_PRINT_HTM(270, 50, 650, 500, allHtml);
      // LODOP.ADD_PRINT_HTM(550, 50, 650, 200, two);
      // LODOP.ADD_PRINT_HTM(650, 50, 650, 200, three);
      // LODOP.ADD_PRINT_HTM(800, 50, 650, 300, four);
      // LODOP.ADD_PRINT_HTM(1150, 50, 650, 350, five);
      // LODOP.ADD_PRINT_HTM(1400, 50, 650, 800, six);
      //打印预览
      LODOP.PREVIEW();
      //LODOP.PRINT_DESIGN();
    },
    //打印殡葬合同
    prinContact(printData) {
      let this_print = this;
      let LODOP = getLodop();
      if (LODOP == null || !LODOP) {
        this_print.$.messager.alert(
          "系统提示",
          "您的浏览器不支持打印控件，请用IE重试或安装打印控件后重试"
        );
        return;
      }

      for (let key in printData) {
        printData[key] = printData[key] ? printData[key] : "　";
      }
      //业务编码
      let businessCode = printData.businessCode;
      let firstParty = "殡仪服务合同";
      //家属或承办人
      let secondParty = printData.firstPartyName;
      //家属联系手机
      let mobilePhone = printData.firstPartyPhone;
      //逝者姓名
      let deadName = printData.deadName;
      //逝者性别
      let deadGender = printData.deadGender;
      //逝者年龄
      let deadAge = printData.deadAge;
      //逝者民族
      let deadNation = printData.deadNation;
      //生前住址
      let beforeDeathAddress = printData.beforeDeathAddress;
      //服务收费项目itemName服务项目 itemCharge服务费用
      let chargeItems = printData.chargeItems;
      //总费用
      let itemTotalCharge = printData.itemTotalCharge;
      //优惠减免明细项itemName服务项目 itemCharge服务费用
      let discountChargeItems = printData.discountChargeItems;
      //实收
      let realityTotalCharge = printData.realityTotalCharge;
      //实收大写
      let realityTotalChargeText = printData.realityTotalChargeText;
      //总减免费用
      //优惠总金额
      let discountTotalCharge = 0;

      if (!(null == printData.discountTotalCharge) || printData.discountTotalCharge.length == 0) {
        discountTotalCharge = new Number(printData.discountTotalCharge);
      }
      //减免总金额
      let benefitTotalCharge =
        (null == printData.benefitTotalCharge) || printData.benefitTotalCharge.length == 0
          ? 0
          : new Number(printData.benefitTotalCharge);
      //甲方工作单位
      let comJia = "";
      //甲方与逝者关系
      let relation = printData.firstPartyRelation;
      //承办方或家属地址
      let firstPartyAddress = printData.firstPartyAddress;

      let proHead =
        "<div style=\"font-size:12px;padding: 2px;\">承办方(以下称甲方) " +
        secondParty +
        "　　 殡仪服务单位:(以下称乙方)临沂市第二殡仪馆\n<br/><br/>";
      let protect =
        "<span>　　 根据《中华人民共和国合同法》、《中华人民共和国消费者权益保护法》、《殡葬管理条例》及相 关法律、法规，结合本次殡仪服务" +
        "的具体内容，甲、乙双方在平等、自愿、公平、诚实信用的基础上， 经协商一致，达成如下协议。</span><br/><br/>";

      let firstInfo = "第一条&emsp;基本信息";

      let firstTable = `
        <style>.tbl td{ padding: 2px; } </style>
        <table line-height="1px" class="tbl" width='700' border='1' cellspacing='0' bordercolor='#000000'
        style='border-collapse:collapse;font-size: 10px;'>
        <tr>
            <td line-height:2em; ">逝者姓名</td>
            <td line-height:2em; style="font-size:13px" colspan="2">${deadName}</td>
            <td line-height:2em;>性别</td>
            <td line-height:2em; style="width: 40px">${deadGender}</td>
            <td line-height:2em;>年龄</td>
            <td line-height:2em; style="width: 40px">${deadAge}</td>
            <td line-height:2em;>民族</td>
            <td line-height:2em; style="width: 60px">${deadNation}</td>
            <td line-height:2em; style='width:50px'>编号</td>
            <td line-height:2em;>${businessCode}</td>
        </tr>
        <tr>
            <td line-height:2em; >逝者身份<br/>证件类型</td>
            <td line-height:2em; colspan="2">${printData.deadCertificateType}</td>
            <td line-height:2em; colspan="2">逝者身份<br/>证件号</td>
            <td line-height:2em; colspan="2">${printData.deadCertificateNo}</td>
            <td line-height:2em; colspan="2">甲方与<br/>逝者关系</td>
            <td line-height:2em; colspan="2">${relation}</td>
        </tr>
        <tr>
            <td line-height:2em; >甲方身份<br/>证件类型</td>
            <td line-height:2em; colspan="2">${printData.firstPartyCertificateType}</td>
            <td line-height:2em; colspan="2">甲方身份<br/>证件号</td>
            <td line-height:2em; colspan="2">${printData.firstPartyCertificateNo}</td>
            <td line-height:2em; colspan="2">甲方联系电话</td>
            <td line-height:2em; colspan="2">${mobilePhone}</td>
        </tr>
        <tr>
            <td line-height:2em;>甲方住址</td>
            <td line-height:2em; colspan="11">${firstPartyAddress}</td>
        </tr>
    </table>`;

      let secondInf = "第二条 服务事项";

      let secondTableHead =
        "<style>.tbl td{ padding: 2px; } </style>" +
        "<table line-height=\"1px\" class=\"tbl\" width='700' border='1' cellspacing='0' bordercolor='#000000'  " +
        "style='border-collapse:collapse;font-size: 10px'>";

      let secondTableBody = "";
      //明细数量
      let itemLength = chargeItems.length;
      let itemHigh = itemLength * 25;
      let itemNumberCount = 0;

      let tableHeader =
        "<tr>" +
        "<td line-height:2em;>服务项目</td><td line-height:2em;>应收费用</td><td line-height:2em;>减免费用</td><td line-height:2em;>实收费用</td>" +
        "<td line-height:2em;>服务项目</td><td line-height:2em;>应收费用</td><td line-height:2em;>减免费用</td><td line-height:2em;>实收费用</td>" +
        "<td line-height:2em;>服务项目</td><td line-height:2em;>应收费用</td><td line-height:2em;>减免费用</td><td line-height:2em;>实收费用</td><tr>"

      let basicServiceChargeItems = printData.basicServiceChargeItems;
      let listBasicServiceTableItem = "";
      if (basicServiceChargeItems && basicServiceChargeItems.length > 0) {
        listBasicServiceTableItem = " <tr style='text-align:center;font-size: 10px;'>" +
          "<td colspan='12' >基本殡葬服务项目</td></tr><tr >";
        listBasicServiceTableItem += tableHeader;
        for (let i = 0; i < basicServiceChargeItems.length; i++) {
          let item = basicServiceChargeItems[i];
          let benefitDiscountCharge = parseFloat(item.itemDiscountCharge) + parseFloat(item.itemBenefitCharge)
          listBasicServiceTableItem +=
            "<td line-height:2em;>" + item.itemName + "</td>" +
            "<td line-height:2em;>" + item.itemCharge + "</td>" +
            "<td line-height:2em;>" + benefitDiscountCharge + "</td>" +
            "<td line-height:2em;>" + item.itemRealityCharge + "</td>";
          if (i !== 0 && (i + 1) % 3 === 0 && i !== basicServiceChargeItems.length - 1) {
            listBasicServiceTableItem += "</tr><tr line-height:2em;>";
          }
          if (i === basicServiceChargeItems.length - 1 && (i + 1) % 3 !== 0) {
            for (let kk = 0; kk < (3 - (i + 1) % 3); kk++) {
              listBasicServiceTableItem +=
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>";
            }
          }
        }
        listBasicServiceTableItem += "</tr>";
        listBasicServiceTableItem += "<tr><td colspan='12' style='font-weight: bold;'>基本殡葬服务项目应收合计：" +
          printData.basicServiceTotalCharge + "&emsp;实收合计:" + printData.basicServiceRealityTotalCharge +
          "</td></tr>";
      }
      let extendServiceChargeItems = printData.extendServiceChargeItems;
      let listExtendServiceTableItem = "";
      if (extendServiceChargeItems && extendServiceChargeItems.length > 0) {

        listExtendServiceTableItem = "  <tr style='text-align:center;font-weight: bold;font-size: 10px;'>" +
          "<td colspan='12'>延伸自愿选择殡葬服务项目</td></tr><tr>";
        listExtendServiceTableItem += tableHeader;
        for (let i = 0; i < extendServiceChargeItems.length; i++) {
          let item = extendServiceChargeItems[i];
          let benefitDiscountCharge = parseFloat(item.itemDiscountCharge) + parseFloat(item.itemBenefitCharge)
          listExtendServiceTableItem +=
            "<td line-height:2em;>" + item.itemName + "</td>" +
            "<td line-height:2em;>" + item.itemCharge + "</td>" +
            "<td line-height:2em;>" + benefitDiscountCharge + "</td>" +
            "<td line-height:2em;>" + item.itemRealityCharge + "</td>";
          if (i !== 0 && (i + 1) % 3 === 0 && i !== extendServiceChargeItems.length - 1) {
            listExtendServiceTableItem += "</tr><tr >";
          }
          if (i === extendServiceChargeItems.length - 1 && (i + 1) % 3 !== 0) {
            for (let kk = 0; kk < (3 - (i + 1) % 3); kk++) {
              1
              listExtendServiceTableItem +=
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>";
            }
          }
        }
        listExtendServiceTableItem += "</tr>";
        listExtendServiceTableItem += "<tr><td colspan='12' style='font-weight: bold;'>延伸自愿选择殡葬服务项目应收合计：" +
          printData.extendServiceTotalCharge + "&emsp;实收合计:" + printData.extendServiceRealityTotalCharge +
          "</td></tr>";
      }


      let listTableBottom =
        "<tr><td colspan='12'>总费用：" +
        itemTotalCharge +
        "　减免：" +
        benefitTotalCharge +
        "　实收：" +
        realityTotalCharge +
        "　大写：" +
        realityTotalChargeText +
        "</td></tr>";

      /*     let listJianMian = "<tr><td colspan='5'>";
           if (discountChargeItems && discountChargeItems.length > 0) {
             for (let j = 0; j < discountChargeItems.length; j++) {
               listJianMian +=
                 discountChargeItems[j].itemName +
                 ":" +
                 discountChargeItems[j].itemCharge;
             }
             listJianMian += "</td></tr>";
           }
           let listRemark = "<tr><td colspan='5'>说明</td></tr>";
           */

      let listTAble =
        listBasicServiceTableItem +
        listExtendServiceTableItem +
        listTableBottom +
        // listJianMian +
        // listRemark +
        "</table>";

      let secondTableButoom = "</table>";
      let secondTable = secondTableHead + listTAble;

      let serviceMessage =
        "<div> 第二条&emsp;服务事项</div>" +
        secondTable +
        "<div> 第三条&emsp;乙方义务 </div>" +
        "<div>  乙方严格按照本合同的内容，保证商品的质量，并按照双方约定的程序及要求，安全、有效、及时的完 成约定的各项服务的事项；" +
        "负责服务过程中由于服务、商品问题导致的甲方投诉的处理，损失的赔偿。 </div>" +
        "<div> 第四条&emsp;甲方义务 </div>" +
        "<div> 甲方应于________之前支付各约定事项的价款。 </div>" +
        "<div> 第五条&emsp;违约责任 </div>" +
        "<div> 乙方未能于约定时间内完成服务工作的，应向甲方支付元违约金；" +
        "甲方擅自解除合同造成乙方 损失的，甲方应予以赔偿乙方损失_________元。其它___________________________ </div>" +
        "<div> 第六条&emsp;争议解决方式 </div>" +
        "<div> 因合同发生的争执，由双方当事人协商解决，或消费者权益保护委员会申请调解，或按第_____种方式进 行解决。</br>" +
        "1）提交仲裁委员会仲裁；2）依法向人民法院起诉。 </div>" +
        "<div> 第七条&emsp;本协议一式贰份，甲方、乙方各持一份，双方签字或盖章后生效。 </div>";

      let tiaoKuan = `<div style="font-size: 12px">
                      <div>
                      </br>
                      </br>家属对遗体是否同意火化：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;是&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;否
                      </div>
                      </br>
                      </br>
                      </br>
                      <div>对以上服务是否满意：
                      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;非常满意
                      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;满意
                      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;不满意
                      </div></div>`;
      let last = `</br>
                  </br>
                  </br>
                  </br>
                  <div>对以上服务及价格无任何异议,完全同意.</div>
                  </br>
                  </br>
                  <div style="text-align:left">请甲方签字确认：<span class='idSpan' style='width: 170px'>&nbsp;</span>
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                  &emsp;&emsp;
                  乙方：临沂市第二殡仪馆</div>
                  <div style="text-align:left">
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;
                  经办人：【${printData.fullName}】</div>
                  <div style="text-align:left">
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;
                  时间：${dataFormate(new Date())}
                  </div>
                  </br>
                  <div style="text-align:left">
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                  &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;
                  公章：<span class='idSpan' style='width: 70px'>
                  </div>
                  </div>
                `;

      let theTitle = "<h4 style='font-size:20px;font-weight: bold;width: 700px;text-align: center;height: 50px'>殡仪服务合同</h4>";

      //纸张
      LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
      //设置字体
      LODOP.SET_PRINT_STYLE("FontSize", 11);
      //调用打印控件进行测试
      LODOP.ADD_PRINT_BARCODE(10, 580, 80, 80, "QRCode", businessCode);
      // LODOP.ADD_PRINT_HTM(
      //   20,
      //   320,
      //   300,
      //   25,
      //   "<p style='font-size:20px;font-weight: bold;'>殡仪服务合同</p>"
      // );
      LODOP.ADD_PRINT_TEXT(90, 550, 300, 25, "服务编码：" + businessCode);
      //打印协议
      // LODOP.ADD_PRINT_HTM(120, 30, 650, 25, proHead);
      // LODOP.ADD_PRINT_HTM(150, 30, 650, 100, protect);
      // //第一条信息
      // LODOP.ADD_PRINT_HTM(210, 30, 650, 25, firstInfo);
      // LODOP.ADD_PRINT_HTM(235, 30, 650, 200, firstTable);
      //let tableHight = itemHigh + 580;

      LODOP.ADD_PRINT_HTM(39, 30, 700, 1000, theTitle + proHead + protect + firstInfo + firstTable + serviceMessage + tiaoKuan + last);
      //打印边框
      //LODOP.ADD_PRINT_RECT(60,55,500,300,0,1);
      // LODOP.ADD_PRINT_TABLE(115,50,300,300,tableStr);
      //直接打印
      //打印预览
      LODOP.PREVIEW();
      //LODOP.PRINT();
      //LODOP.PRINT_DESIGN();
    },
    //打印服务协议单最新
    printServiceProtocol(printData) {
      let this_print = this;
      let LODOP = getLodop();
      if (LODOP == null || !LODOP) {
        this_print.$.messager.alert(
          "系统提示",
          "您的浏览器不支持打印控件，请用IE重试或安装打印控件后重试"
        );
        return;
      }

      for (let key in printData) {
        // console.log(printData[key], "打印服务协议printData[key]")
        printData[key] = printData[key] ? printData[key] : "　";
      }
      console.log(printData, 8888888888888888888);

      //服务收费项目itemName服务项目 itemCharge服务费用
      let chargeItems = printData.chargeItems;

      //总费用
      let itemTotalCharge = printData.itemTotalCharge;
      //优惠减免明细项itemName服务项目 itemCharge服务费用
      let discountChargeItems = printData.discountChargeItems;
      //实收
      let realityTotalCharge = printData.realityTotalCharge;
      //实收大写
      let realityTotalChargeText = printData.realityTotalChargeText;
      //优惠总金额
      let discountTotalCharge = 0;
      //家属或承办人
      let secondParty = printData.firstPartyName;

      if (!(null == printData.discountTotalCharge) || printData.discountTotalCharge.length == 0) {
        discountTotalCharge = new Number(printData.discountTotalCharge);
      }
      //减免总金额
      let benefitTotalCharge =
        (null == printData.benefitTotalCharge) || printData.benefitTotalCharge.length == 0
          ? 0
          : new Number(printData.benefitTotalCharge);

      let protect =
        "<div style=\"font-size:8px\">承办方(以下称甲方) " +
        secondParty +
        "　　 殡仪服务单位:(以下称乙方)临沂市第二殡仪馆 <br/><br/>" +
        "　　根据《中华人民共和国合同法》、《中华人民共和国消费者权益保护法》、《殡葬管理条例》及相关法律、" +
        "法规，结合本次殡仪服务的具体内容，甲、乙双方在平等、自愿选择、公平、诚实信用的基础上，经协商一致，达成" +
        "如下协议。<br/><br/>";

      let proHead = `<style>.tbl td{ padding: 2px; } </style>
        <table line-height="1px" class="tbl" width='700' border='1' cellspacing='0' bordercolor='#000000'
        style='border-collapse:collapse;font-size: 10px;'>
        <tr height="1px">
            <td line-height:2em; style="width: 80px;">逝者姓名</td>
            <td line-height:2em; style="font-size:13px" colspan="2">${printData.deadName}</td>
            <td line-height:2em; line-height:2em;>性别</td>
            <td line-height:2em; style="width: 40px">${printData.deadGender}</td>
            <td line-height:2em; line-height:2em;>年龄</td>
            <td line-height:2em; style="width: 40px">${printData.deadAge}</td>
            <td line-height:2em; line-height:2em;>民族</td>
            <td line-height:2em; style="width: 60px">${printData.deadNation}</td>
            <td line-height:2em; style='width:50px'>编号</td>
            <td line-height:2em; line-height:2em;>${printData.businessCode}</td>
        </tr>
        <tr height="1px">
            <td line-height:2em; >逝者身份<br/>证件类型</td>
            <td line-height:2em; colspan="2">${printData.deadCertificateType}</td>
            <td line-height:2em; colspan="2">逝者身份<br/>证件号</td>
            <td line-height:2em; colspan="2">${printData.deadCertificateNo}</td>
            <td line-height:2em; colspan="2">甲方与<br/>逝者关系</td>
            <td line-height:2em; colspan="2">${printData.firstPartyRelation}</td>

        </tr>
        <tr height="1px">
            <td line-height:2em; >甲方身份<br/>证件类型</td>
            <td line-height:2em; colspan="2">${printData.firstPartyCertificateType}</td>
            <td line-height:2em; colspan="2">甲方身份<br/>证件号</td>
            <td line-height:2em; colspan="2">${printData.firstPartyCertificateNo}</td>
            <td line-height:2em; colspan="2">甲方联系电话</td>
            <td line-height:2em; colspan="2">${printData.firstPartyPhone}</td>
        </tr>
        <tr height="1px">
            <td line-height:2em; line-height:2em;>甲方住址</td>
            <td line-height:2em; colspan="10">${printData.firstPartyAddress}</td>
        </tr>
    </table>`;

      //客户定制需求，暂时不需要该条目显示
      /*
            <div><span  style='font-weight: bolder'>注</span>：甲方有责任及义务,对所提供的身份证、户口本,《居民死亡推断书》等证件真实有效。如果甲方提供的上述手续不真实,出现责任、纠纷等问题,甲方负全部责任。遗体 存放期间家属查看遗体时，必须出具甲方签订人有效证件。甲方签字人非逝者近亲属签订协议后，一日内将本协议内容告知逝者近亲属。</div>
            <div>注：收费收费依据为潍发改物价<2018>73号文件第二条规定</div>
      */

      /*
            let secondTableHead =
              " <table border='1' cellspacing='0' bordercolor='#000000' width = 700 style='border-collapse:collapse;font-size:12px;'><tr><td line-height:2em;>服务项目</td><td line-height:2em;>费用</td><td line-height:2em;>服务项目</td><td line-height:2em;>费用</td><td line-height:2em;>服务项目</td><td>费用</td></tr>";
      */

      //明细数量
      let listTableItem = "<tr>";
      if (chargeItems && chargeItems.length > 0) {
        for (let i = 0; i < chargeItems.length; i++) {

          let item = chargeItems[i];
          listTableItem +=
            "<td>" + item.itemName + "</td><td>" + item.itemCharge + "</td>";
          if (i !== 0 && (i + 1) % 3 === 0 && i !== chargeItems.length - 1) {
            listTableItem += "</tr><tr>";
          }
          if (i === chargeItems.length - 1 && (i + 1) % 3 !== 0) {
            for (let kk = 0; kk < (3 - (i + 1) % 3); kk++) {
              listTableItem += "<td>&nbsp;</td><td>&nbsp;</td>";
            }
          }
        }
        listTableItem += "</tr>";
      }
      let listTableBottom =
        "<tr><td colspan='10'>总费用：" +
        itemTotalCharge +
        "　减免：" +
        benefitTotalCharge +
        "　实收：" +
        realityTotalCharge +
        "　大写：" +
        realityTotalChargeText +
        "</td></tr>";
      let listJianMian = "<tr><td colspan='5'>";
      if (discountChargeItems && discountChargeItems.length > 0) {
        for (let j = 0; j < discountChargeItems.length; j++) {
          listJianMian +=
            discountChargeItems[j].itemName +
            ":" +
            discountChargeItems[j].itemCharge;
        }
        listJianMian += "</td></tr>";
      }
      //let listRemark = "<tr><td colspan='5'>说明</td></tr>";
      let listTAble =
        "<table border='1'  cellspacing='0' bordercolor='#000000' width = 700 style='border-collapse:collapse;'>" +
        "<tr><td>服务项目</td><td> 费用</td> <td>服务项目</td><td> 费用</td> <td>服务项目</td><td> 费用</td><tr>" +
        listTableItem +
        listTableBottom +
        "</table>";

      let tableHeader =
        "<tr>" +
        "<td line-height:2em;>服务项目</td><td line-height:2em;>应收费用</td><td line-height:2em;>减免费用</td><td line-height:2em;>实收费用</td>" +
        "<td line-height:2em;>服务项目</td><td line-height:2em;>应收费用</td><td line-height:2em;>减免费用</td><td line-height:2em;>实收费用</td>" +
        "<td line-height:2em;>服务项目</td><td line-height:2em;>应收费用</td><td line-height:2em;>减免费用</td><td line-height:2em;>实收费用</td><tr>"

      let basicServiceChargeItems = printData.basicServiceChargeItems;
      let listBasicServiceTableItem = "";
      if (basicServiceChargeItems && basicServiceChargeItems.length > 0) {
        listBasicServiceTableItem = " <tr style='text-align:center;font-weight: bold;font-size: 10px;'>" +
          "<td colspan='12' >基本殡葬服务项目</td></tr><tr >";
        listBasicServiceTableItem += tableHeader;
        for (let i = 0; i < basicServiceChargeItems.length; i++) {
          let item = basicServiceChargeItems[i];
          let benefitDiscountCharge = parseFloat(item.itemDiscountCharge) + parseFloat(item.itemBenefitCharge)
          listBasicServiceTableItem +=
            "<td line-height:2em;>" + item.itemName + "</td>" +
            "<td line-height:2em;>" + item.itemCharge + "</td>" +
            "<td line-height:2em;>" + benefitDiscountCharge + "</td>" +
            "<td line-height:2em;>" + item.itemRealityCharge + "</td>";
          if (i !== 0 && (i + 1) % 3 === 0 && i !== basicServiceChargeItems.length - 1) {
            listBasicServiceTableItem += "</tr><tr line-height:2em;>";
          }
          if (i === basicServiceChargeItems.length - 1 && (i + 1) % 3 !== 0) {
            for (let kk = 0; kk < (3 - (i + 1) % 3); kk++) {
              listBasicServiceTableItem +=
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>";
            }
          }
        }
        listBasicServiceTableItem += "</tr>";
        listBasicServiceTableItem += "<tr><td colspan='12' style='font-weight: bold;'>基本殡葬服务项目应收合计：" +
          printData.basicServiceTotalCharge + "&emsp;实收合计:" + printData.basicServiceRealityTotalCharge +
          "</td></tr>";
      }
      let extendServiceChargeItems = printData.extendServiceChargeItems;
      let listExtendServiceTableItem = "";
      if (extendServiceChargeItems && extendServiceChargeItems.length > 0) {

        listExtendServiceTableItem = "  <tr style='text-align:center;font-weight: bold;font-size: 10px;'>" +
          "<td colspan='12'>延伸自愿选择殡葬服务项目</td></tr><tr>";
        listExtendServiceTableItem += tableHeader;
        for (let i = 0; i < extendServiceChargeItems.length; i++) {
          let item = extendServiceChargeItems[i];
          let benefitDiscountCharge = parseFloat(item.itemDiscountCharge) + parseFloat(item.itemBenefitCharge)
          listExtendServiceTableItem +=
            "<td line-height:2em;>" + item.itemName + "</td>" +
            "<td line-height:2em;>" + item.itemCharge + "</td>" +
            "<td line-height:2em;>" + benefitDiscountCharge + "</td>" +
            "<td line-height:2em;>" + item.itemRealityCharge + "</td>";
          if (i !== 0 && (i + 1) % 3 === 0 && i !== extendServiceChargeItems.length - 1) {
            listExtendServiceTableItem += "</tr><tr >";
          }
          if (i === extendServiceChargeItems.length - 1 && (i + 1) % 3 !== 0) {
            for (let kk = 0; kk < (3 - (i + 1) % 3); kk++) {
              1
              listExtendServiceTableItem +=
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>" +
                "<td line-height:2em;>&nbsp;</td>";
            }
          }
        }
        listExtendServiceTableItem += "</tr>";
        listExtendServiceTableItem += "<tr><td colspan='12' style='font-weight: bold;'>延伸自愿选择殡葬服务项目应收合计：" +
          printData.extendServiceTotalCharge + "&emsp;实收合计:" + printData.extendServiceRealityTotalCharge +
          "</td></tr>";
      }

      let serviceTable = " <style>.tbl td{ padding: 2px; } </style>" +
        "<table line-height=\"1px\" class=\"tbl\" width='700' border='1' cellspacing='0' bordercolor='#000000'  style='border-collapse:collapse;font-size: 10px'>" +
        listBasicServiceTableItem +
        listExtendServiceTableItem +
        listTableBottom +
        "</table>";
      //let secondTableButoom = "</table>";
      //let secondTable = secondTableHead + listTableItem + secondTableButoom;
      let arrayTitle = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十'];
      let countTitle = 0;
      let allHtml = "<style>" +
        ".idSpan {\n" +
        "                    display: inline-block;\n" +
        "                    border-bottom: 1px solid;\n" +
        "                    margin: 2px;\n" +
        "                    text-align: center;\n" +
        "                }" +
        "</style>";
      allHtml += protect;
      allHtml += proHead;

      //allHtml+=listTAble;
      //收费项目信息
      if (printData.chargeItems.length > 0) {
        let zero = `<h4> ` + arrayTitle[countTitle] + `、收费项目、价格、金额： </h4>
        ${serviceTable}`;
        countTitle++;
        allHtml += zero;
      }

      let space = `&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`;
      /*  if (printData.isCold == 1) {
          let one = `<h4> ` + arrayTitle[countTitle] + `、遗体冷藏服务及规定： </h4>
        <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTime}】起存放在殡仪馆冷藏。
        <div>注： 因尸体腐败、异味、传染病等原因，每日加收90元 以此类推。</div>
        </div>
        <div>2.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>
        <div>3.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
  `;
          countTitle++;
          allHtml += one;
        }*/
      if (printData.isJieDong === 1) {
        let two = `
      <h4> ` + arrayTitle[countTitle] + `、遗体解冻服务： </h4>
      <div>1.	应甲方要求，乙方提前将逝者遗体进行解冻，为确保遗体按时解冻及安全，存在于特定房间，收费【${printData.jieDongCharge}】元。</div>
      <div>2.	甲方要求乙方帮助搬运遗体的，乙方将按规定另收取搬运费。</div>
      <div>3.	化冻期间受个体差异因素的影响，可能会发生遗体变色发黑、变形渗血等不确定因素与化冻前可能有较大的差别，乙方均不承担责任。</div>
    `;
        countTitle++;
        allHtml += two;
      }

      if (printData.isDanJian === 1) {
        let three = `<h4> ` + arrayTitle[countTitle] + `、单间冷藏租用服务： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTimeDanJian}】起存放在殡仪馆单间冷藏柜(柜号：${printData.equipmentCodeDanJian})冷藏,价格由双方协商确定。
      </div>
      <div>2.	乙方应甲方要求，提供单间冷藏柜租用，甲方遵循乙方单间冷藏柜使用管理规定，严禁在室内使用明火，因甲方违反规定造成的后果甲方负责。  </div>
      <div>3.	乙方应配有消防器材且不定时查看，遇有违反规定的应及时制止，甲方应积极配合，自觉服从管理。</div>
      <div>4.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
      <div>5.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>

`;
        countTitle++;
        allHtml += three;
      }
      if (printData.isDanTi === 1) {
        let three = `<h4> ` + arrayTitle[countTitle] + `、恒温冷藏租用服务： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTimeDanTi}】起存放在殡仪馆恒温冷藏柜(柜号：${printData.equipmentCodeDanTi})冷藏,价格由双方协商确定。
      </div>
      <div>2.	乙方应甲方要求，提供恒温冷藏柜租用，甲方遵循乙方恒温冷藏柜使用管理规定，严禁在室内使用明火，因甲方违反规定造成的后果甲方负责。  </div>
      <div>3.	乙方应配有消防器材且不定时查看，遇有违反规定的应及时制止，甲方应积极配合，自觉服从管理。</div>
      <div>4.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
      <div>5.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>

`;
        countTitle++;
        allHtml += three;
      }
      if (printData.isShouLingEquipmentType === 1) {
        let three = `<h4> ` + arrayTitle[countTitle] + `、守灵室冷藏租用服务： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTimeShouLing}】起存放在殡仪馆守灵室冷藏柜(柜号：${printData.equipmentCodeShouLing})冷藏,价格由双方协商确定。
      </div>
      <div>2.	乙方应甲方要求，提供守灵室冷藏柜租用，甲方遵循乙方守灵室冷藏柜使用管理规定，严禁在室内使用明火，因甲方违反规定造成的后果甲方负责。  </div>
      <div>3.	乙方应配有消防器材且不定时查看，遇有违反规定的应及时制止，甲方应积极配合，自觉服从管理。</div>
      <div>4.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
      <div>5.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>

`;
        countTitle++;
        allHtml += three;
      }
      if (printData.isPuTongEquipmentType === 1) {
        let three = `<h4> ` + arrayTitle[countTitle] + `、普通冷藏柜租用服务： </h4>
      <div>1.甲方自愿将逝者${printData.deadName}遗体由【${printData.coldInTimePuTong}】起存放在殡仪馆普通冷藏柜(柜号：${printData.equipmentCodePuTong})冷藏,价格为80每天,不足12小时按半天计算。
      <div>注： 因尸体腐败、异味、传染病等原因，每日加收90元 以此类推。</div>
      </div>
      <div>2.	乙方应甲方要求，提供普通冷藏柜租用，甲方遵循乙方普通冷藏柜使用管理规定，严禁在室内使用明火，因甲方违反规定造成的后果甲方负责。  </div>
      <div>3.	乙方应配有消防器材且不定时查看，遇有违反规定的应及时制止，甲方应积极配合，自觉服从管理。</div>
      <div>4.	遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置时随时通知甲方转运冷藏遗体。</div>
      <div>5.	遗体存放前，甲方必须将遗体随身的贵重物品取出，遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。</div>

`;
        countTitle++;
        allHtml += three;
      }

      //是否勾选馆外尸体搬运费
      if (printData.isGuanWaiYiTiBanYuan === 1) {
        let twentyOne = `<h4> ` + arrayTitle[countTitle] + `、遗体收抬服务协议： </h4>
      <div>1.	应甲方家属要求，乙方将甲方逝者${printData.deadName}特殊遗体由______________________收抬至
      临沂市第二殡仪馆。双方协商收抬费用合计：【${printData.guanWaiYiTiBanYuanChargeText}】 元。</div>
       `;
        countTitle++;
        allHtml += twentyOne;
      }

      if (printData.isGaoBie === 1) {
        let four = `<h4> ` + arrayTitle[countTitle] + `、遗体告别仪式服务： </h4>
      <div>1、应甲方要求，乙方为甲方提供遗体告别仪式服务，甲方初步拟订告别时间后通知乙方，乙方根据告别情况具体安排，时间的最终确定由甲、乙双方商定；不能随意变更，确有特殊情况需调整时间的，必须事先通知乙方，征得同意后，方可调整，但不得影响已预订的其他告别。</div>
      <div>2、甲方确定【${printData.gaoBieTime}】为逝者${printData.deadName}在临沂市第二殡仪馆【${printData.gaoBieTing}】举行遗体告别仪式。</div>
      <div>3、告别前半小时，乙方可组织甲方人员，将逝者遗体搬运至告别厅，搬运前甲方要对遗体进行确认并签字。举行遗体告别仪式前，乙方负责组织参加告别的人员列队和亲属的站位，甲方有义务积极配合乙方。</div>
      <div>4、告别期间，因供电方停电或线路出现故障，造成音响、LED显示屏不能正常使用，乙方不承担责任，有义务积极联系排除故障，尽快恢复。告别中，乙方可指导亲属文明治丧，没有义务必须按当地习俗礼仪帮助主持丧事。</div>
`;

        countTitle++;
        allHtml += four;
        let five = `<h4> ` + arrayTitle[countTitle] + `、 租用告别厅和告别厅鲜花租用服务： </h4>
      <div>1、应甲方要求，乙方提前将告别厅将鲜花摆放装饰好。乙方原因无法提供鲜花服务时，
      应提前12小时通知甲方终止本协议。双方互不承担责任。甲方确定租用告别厅和告别厅内租用鲜花装饰，价格由双方协商确定。
      </div>
      <div>2.因鲜花受季节影响较大，具体造型、花色等以现场实物为准。鲜花及造型在使用过程中会发生细微的变色或变形，属鲜花使用过程中的正常现象。甲方应提醒随同人员不要随意变动造型和拿取鲜花。因甲方原因造成的鲜花造型改变和丢失，应甲方负责，乙方不承担责任。</div>
`;
        countTitle++;
        allHtml += five;

        let seven = `<h4> ` + arrayTitle[countTitle] + `、遗体棺内装饰服务： </h4>
            <div>1 应甲方要求，乙方为甲方逝者提供鲜花装饰服务，价格由双方协商确定。</div>
               `;
        countTitle++;
        allHtml += seven;
      }

      if (printData.isSongLingService === 1) {

        let six = `<h4> ` + arrayTitle[countTitle] + `、送灵服务： </h4>
      <div>1、 应甲方家属要求，乙方为甲方逝者${printData.deadName}提供遗体送灵服务，甲方初步拟订送灵时间后通知乙方
      ，乙方根据实际情况具体安排，甲方遵从乙方人员安排，具体费用由乙方告知甲方，
      甲方同意后签订服</br></br>务协议，商定时间______  年______  月______  日______  时______  分。
      确有特殊情况需调整时间的，必须事先通知乙方，征得同意后方可调整。</div>`;
        countTitle++;
        allHtml += six;
      }

      if (printData.isFaceLift == 1) {

        let eight = `<h4> ` + arrayTitle[countTitle] + `、遗体整容服务： </h4>
                <div>1、应甲方要求，乙方为逝者提供整形、化妆、美容美发、净身、缝合、穿脱衣等服务。因遗体出现________________________情况
                ，价格由双方协商确定。由于人去世后面容会有较大的变化，整容期间受个体差异因素的影响
                ，可能会发生遗体变色、变形、渗血、伤口开裂；整容后与生前可能仍有一定的差别
                ，甲方应予以谅解；遗体整容前，甲方必须将遗体随身的贵重物取出另行保管，如发生遗失、损坏等上述情况
                ，乙方均不承担责任。
                </div> `;
        countTitle++;
        allHtml += eight;
      }
      if (printData.isShouLing == 1) {

        let nine = `<h4>` + arrayTitle[countTitle] + `、守灵室冷藏服务： </h4>
                <div> 1、甲方自愿将逝者【${printData.deadName}】遗体由【${printData.shouLingBeginTime}】起
                存放在殡仪馆豪华冷藏守灵室。</div>

                <div> 2、遗体存放前，甲方必须将遗体随身的贵重物品取出。遗体长期冷冻存放会造成变色、变形、渗血、出现异味、伤口开裂、脱水、结冰、变色、结霜、卫生棺受潮损坏、衣物霉变等情况，属于遗体冷冻存放过程中的正常现象。非乙方原因造成遗体损坏、丢失、被抢等，乙方不承担责任。
                <div>3、遗体存放期间，乙方根据设备运行情况需要调整遗体存放位置随时通知甲方转存遗体。</div>


            `;
        countTitle++;
        allHtml += nine;
      }
      //客户定制需求，暂时不需要该条目显示
      /*if (printData.isYiXiang == 1) {
             let ten = `
           <h4> ` + arrayTitle[countTitle] + `、遗像： </h4>
           <div>1、应甲方要求，乙方为逝者制作遗像【${printData.yiXiangCharge}】元/次（包括相片放大、黑纱、相框）。由甲方提供逝者生前一寸或二寸照片。</div>
           <div>2、原照片质量影响制作遗像质量。因原照片质量出现的问题由甲方负责，因乙方制作过程中出现问题由乙方负责。制作遗像过程中，可能会发生很细微的色差，属于正常现象。</div>
         `;
             countTitle++;
             allHtml += ten;
           }*/
      //客户定制需求，暂时不需要该条目显示
      /* if (printData.isCiXiang == 1) {
             let eleven = ` <h4> ` + arrayTitle[countTitle] + `、瓷像： </h4>
           <div>1、应甲方要求，乙方为逝者制作烤瓷像【${printData.ciXiangCharge}】元/次 。由甲方提供逝者生前一寸或二寸照片。</div>
           <div>2、原照片质量影响制作烤瓷像质量。因原照片质量出现的问题由甲方负责，因乙方制作过程中出现问题由乙方负责。制作遗像过程中，可能会发生很细微的色差，属于正常现象。</div>`;
             countTitle++;
             allHtml += eleven;
           }*/
      //客户定制需求，暂时不需要该条目显示
      /*    if (printData.isHuaShu == 1) {
            let twelve = ` <h4> ` + arrayTitle[countTitle] + `、鲜花花束： </h4>
          <div>提倡文明环保殡葬原则，本着家属自愿选择，对遗体瞻仰提供鲜花送别服务【${printData.huaShuCharge}】元/束</div>`;
            countTitle++;
            allHtml += twelve;
          }*/
      //客户定制需求，暂时不需要该条目显示
      /*
           //是否勾选火化
           if (printData.isChooseCremation === 1) {
             let twenty = `<h4> ` + arrayTitle[countTitle] + `、特殊火化声明： </h4>
           <div>1. 我对逝者死因无异议、未报警，同意火化，并承诺向殡仪馆提供的信息真实，因信息不实造成的所有后果由自己承担
           ，与临沂市第二殡仪馆无关。</br></br></br>以上条款我已阅读明白，特立据______________________。</div>
         `;
             countTitle++;
             allHtml += twenty;
           }
     */
      //客户定制需求，暂时不需要该条目显示
      /*
            tiaoKuan = `<h4>` + arrayTitle[countTitle] + `、如有补充协议以补充协议为准</h4>`;
            countTitle++;
            allHtml += tiaoKuan;

            //合同条款
            let tiaoKuan = `<h4>` + arrayTitle[countTitle] + `、甲乙双方义务责任： </h4>
                            <div>1、乙方保证商品的质量如实描述，严格遵照本合同的内容,按照双方约定的程序及要求,安全、有效、及时地完成各约定的服务事项。</div>
                            <div>2、乙方负责服务过程中由于服务、商品导致的问题乙方积极的处理,及时按照甲方要求改进服务方案、退换货，为甲方提供满意的服务及商品。</div>
                            <div>3、甲方应于<span class='idSpan' style='font-weight: bolder'>当日</span> 付清约定事项的价款。</div>
                            <div>4、甲方同意上述收费明细及以下服务事项的内容,并再次确认无误,有异议,请当场提出。
                            </br>
                            </br>
                            </div>
                            <div style="font-size: 12px">
                            <div>5、家属对遗体是否同意火化：&emsp;&emsp;&emsp;是&emsp;&emsp;&emsp;否</div>
                            </br>
                            </br>
                            </br>
                            <div>6、对以上服务是否满意：
                            &emsp;&emsp;&emsp;非常满意
                            &emsp;&emsp;&emsp;满意
                            &emsp;&emsp;&emsp;不满意
                            </div>
            `;
            countTitle++;
            allHtml += tiaoKuan;
      */

      /* tiaoKuan=`<h4>` + arrayTitle[countTitle] + `、甲方义务： </h4>
                 <div>甲方应于<span class='idSpan' style='font-weight: bolder'>当日</span> 付清约定事项的价款。</div>
 `;
       countTitle++;
       allHtml += tiaoKuan;

       tiaoKuan=`<h4>` + arrayTitle[countTitle] + `、甲方责任： </h4>
                 <div>甲方同意上述第一条收费明细及以下服务事项的内容,井再次确认无误,有异议,请当场提出<span class='idSpan' style='width: 50px'>　</span><br/><span class='idSpan' style='width: 300px'>&nbsp;</span></div>
 `;
       countTitle++;
       allHtml += tiaoKuan;
 */
      /*   tiaoKuan=`<h4>` + arrayTitle[countTitle] + `、甲方承诺： </h4>
                    <div>甲方有责任及义务,对所提供的身份证、户口本,《居民死亡推断书》等证件真实有效。如果甲方提供的上述手续不真实,出现责任、纠纷等问题,甲方负全部责任。</div>
    `;*/
      /*     tiaoKuan = `<h4> </h4>`;
           countTitle++;
           allHtml += tiaoKuan;
     */
      //if (printData.is)

// <div>甲方必须提供本协议涉及的信息真实、准确，因信息不实造成的所有后果由甲方承担。遗体 存放期间家属查看遗体时，必须出具甲方签订人有效证件。甲方签字人非逝者近亲属签订协议后，一日内将本协议内容告知逝者近亲属。<br/></div>
      let last = `
      </br>
      </br>
      </br>
      </br>
      <div>对以上服务及价格无任何异议,完全同意.</div>
      </br>
      </br>
      <div style="text-align:left">请甲方签字确认：<span class='idSpan' style='width: 170px'>&nbsp;</span>
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      乙方：临沂市第二殡仪馆</div>
      <div style="text-align:left">
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      经办人：【${printData.fullName}】</div>
      <div style="text-align:left">
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      时间：${dataFormate(new Date())}
      </div>
      </br>
      <div style="text-align:left">
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;
      &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
      公章：<span class='idSpan' style='width: 70px'>
      </div></div>`;
      allHtml += last;
      //客户定制需求，暂时不需要该条目显示
      /*
          </br>
            </br>
            <div  style="BORDER-TOP: #1b1c1c 3px dashed; OVERFLOW: hidden; HEIGHT: 3px"></div>
            </br>
            </br>
            <div style="font-size: 18px">注：票据领取 火化证，发票，明细单请承办人确认领取<span class='idSpan' style='font-weight: bolder; width: 150px'>&nbsp;</span></div>
            </br>
            </br>
            </br>
            <div style="font-size: 18px">对以上服务是否满意：<span class='idSpan' style='width: 200px'>　</span>
      */


      let theTitle = "<p style='font-size:25px;font-weight: bold;width: 700px;height: 80px; text-align: center'>殡仪服务协议</p>";

      //纸张
      LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
      //设置字体
      LODOP.SET_PRINT_STYLE("FontSize", 11);
      //调用打印控件进行测试
      LODOP.ADD_PRINT_BARCODE("4mm", "160mm", "28mm", "28mm", "QRCode", printData.businessCode);
      LODOP.SET_PRINT_STYLEA(0, "QRCodeVersion", 2);
      LODOP.SET_PRINT_STYLEA(0, "DataCharset", "UTF-8");
      LODOP.ADD_PRINT_TEXT("27mm", "140mm", 300, 25, "业务编码：" + printData.businessCode);

      //打印协议
      LODOP.ADD_PRINT_HTM(20, 50, 650, 1000, theTitle + allHtml);
      //打印预览
      LODOP.PREVIEW();
      //LODOP.PRINT();
      //LODOP.PRINT_DESIGN();
    }, //获取打印服务协议数据
    getServiceAgreement() {
      //查询服务协议接口数据
      let this_print = this;
      let postData = {
        businessCode: this_print.businessCode,
      };
      Type["loadPrintServiceProtocolWithBusinessCode"](postData)
        .then((response) => {
          //接收返回数据

          let result = response.data;
          //调用打印接口
          this_print.printServiceProtocol(result);
        })
        .catch((error) => {
          this_print.$message(error);
        });
    }, //打印合同
    getPrintContact() {
      //查询服务协议接口数据
      let this_print = this;
      let postData = {
        businessCode: this_print.businessCode,
      };
      Type["loadPrintContractWithBusinessCode"](postData)
        .then((response) => {
          //接收返回数据

          let result = response.data;
          //调用打印接口
          this_print.prinContact(result);
        })
        .catch((error) => {
          this_print.$message(error);
        });
    }, //打印逝者二维码
    printCremationArchivesCode(printData) {
      let this_print = this;
      let LODOP = getLodop();
      if (LODOP == null || !LODOP) {
        this_print.$.messager.alert(
          "系统提示",
          "您的浏览器不支持打印控件，请用IE重试或安装打印控件后重试"
        );
        return;
      }

      for (let key in printData.funeralDead) {
        printData["funeralDead"][key] = printData["funeralDead"][key]
          ? printData["funeralDead"][key]
          : "　";
      }
      console.log(printData.funeralDead, 666)
      //业务编码
      let businessCode = printData.funeralDead.businessCode;
      //逝者姓名
      let deadName = printData.funeralDead.deadName;
      //逝者死亡原因
      let deathCause = printData.funeralDead.deathCause;
      //逝者年龄
      let deadAge = printData.funeralDead.deadAge;
      //殡仪馆
      let firstParty = "XX殡仪馆";
      //逝者家属
      let memberName = printData.familyMember.memberName;
      //家属联系手机
      let mobilePhone = printData.familyMember.mobilePhone;

      //逝者性别
      let deadGender = printData.funeralDead.deadGender;
      //纸张
      //LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
      //设置字体
      // LODOP.SET_PRINT_STYLE("FontSize", 11);
      // //调用打印控件进行测试
      // LODOP.ADD_PRINT_BARCODE(39, 50, 100, 100, "QRCode", businessCode);
      // LODOP.ADD_PRINT_TEXT(39, 150, 350, 25, businessCode);
      // LODOP.ADD_PRINT_HTM(60, 150, 300, 25, "逝者: " + deadName);
      // LODOP.ADD_PRINT_TEXT(
      //   90,
      //   150,
      //   350,
      //   25,
      //   "性别：" + deadGender + "年龄:" + deadAge
      // );
      // LODOP.ADD_PRINT_HTM(120, 150, 300, 25, deathCause);
      // LODOP.ADD_PRINT_TEXT(150, 150, 300, 25, "家属姓名：" + memberName);


      LODOP.PRINT_INITA("0mm", "0mm", "68.8mm", "38.6mm", "二维条形码打印");
      LODOP.ADD_PRINT_BARCODE("3.4mm", "2.4mm", "29.9mm", "29.9mm", "QRCode", businessCode);
      LODOP.SET_PRINT_STYLEA(0, "QRCodeVersion", 2);
      LODOP.SET_PRINT_STYLEA(0, "DataCharset", "UTF-8");
      LODOP.ADD_PRINT_TEXT("8.5mm", "31.2mm", "36.5mm", "6.6mm", deadName);
      LODOP.SET_PRINT_STYLEA(0, "FontName", "微软雅黑");
      LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
      LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
      LODOP.ADD_PRINT_TEXT("14.3mm", "41mm", "10.6mm", "5.6mm", deadAge);
      LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
      LODOP.ADD_PRINT_TEXT("14.3mm", "31.8mm", "8.2mm", "6.6mm", deadGender);
      LODOP.SET_PRINT_STYLEA(0, "FontSize", 11);
      LODOP.ADD_PRINT_TEXT("3.4mm", "31.2mm", "36.5mm", "6.6mm", businessCode);
      LODOP.SET_PRINT_STYLEA(0, "FontSize", 9);
      LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
      LODOP.SET_PRINT_STYLEA(0, "LineSpacing", "-1.1mm");
      LODOP.SET_PRINT_STYLEA(0, "LetterSpacing", "0.3mm");
      LODOP.ADD_PRINT_TEXT("20.4mm", "31.8mm", "35.5mm", "6.6mm", deathCause);
      LODOP.SET_PRINT_STYLEA(0, "FontSize", 9);
      LODOP.ADD_PRINT_TEXT("26mm", "31mm", "67.6mm", "6.6mm", "联系方式：" + mobilePhone);
      LODOP.SET_PRINT_STYLEA(0, "FontSize", 9);
      LODOP.ADD_PRINT_TEXT("30mm", "31mm", "70.6mm", "6.6mm", "家属姓名：" + memberName);
      LODOP.SET_PRINT_STYLEA(0, "FontSize", 9);
      LODOP.ADD_PRINT_TEXT(121, 11, 100, 25, "遗体条码");


      //打印边框
      //LODOP.ADD_PRINT_RECT(60,55,500,300,0,1);
      // LODOP.ADD_PRINT_TABLE(115,50,300,300,tableStr);
      //直接打印
      //打印预览
      LODOP.PREVIEW();
      //LODOP.PRINT();
      //LODOP.PRINT_DESIGN();
    }, //获取打印逝者二维码数据
    getCremationArchivesCode() {
      //查询服务协议接口数据
      let this_print = this;
      let postData = {
        businessCode: this_print.businessCode,
      };
      Type["loadPrintCremationArchivesCodeWithBusinessCode"](postData)
        .then((response) => {
          //接收返回数据

          let result = response.data;
          //调用打印接口
          this_print.printCremationArchivesCode(result);
        })
        .catch((error) => {
          this_print.$message(error);
        });
    },
    //获取打印减免数据
    PrintAbatementList() {
      {
        if (!this.businessCode || this.businessCode.length === 0) {
          this.$message("请输入业务编码");
          return;
        }
        let postData = {
          businessCode: this.businessCode,
        };
        Type["loadPrintServiceChargeExemptionInfoWithBusinessCode"](
          postData
        ).then((response) => {
          const {data} = response;
          if (!data) {
            this.$message("数据读取失败");
            return;
          }
          this.PrintAbatement(data);
        });
      }
    },
    //打印减免基本殡葬服务费用申请表
    PrintAbatement(printData) {
      let this_print = this;
      let LODOP = getLodop();
      if (LODOP == null || !LODOP) {
        this_print.$.messager.alert(
          "系统提示",
          "您的浏览器不支持打印控件，请用IE重试或安装打印控件后重试"
        );
        return;
      }

      console.log(printData)

      for (let key in printData.funeralDead) {
        printData["funeralDead"][key] = printData["funeralDead"][key]
          ? printData["funeralDead"][key]
          : "　";
      }

      for (let key in printData.familyAgent) {
        printData["familyAgent"][key] = printData["familyAgent"][key]
          ? printData["familyAgent"][key]
          : "　";
      }

      let trStr = "";
      for (let i = 0; i < printData.chargeItems.length; i++) {
        trStr += `
            <br>服务项目:&ensp;${printData.chargeItems[i].itemName}&ensp;
            减免金额:&ensp;${printData.chargeItems[i].benefitCharge}`;
      }
      let dateStr = printData.currentDate;
      // let date = new Date();
      // //获取年
      // let dateYear = date.getFullYear();
      // //获取月
      // let dateMonth = date.getMonth();
      // //获取当日
      // let dateDate = date.getDate();
      let recOperationcode = printData.recCode;
      let table = `<table style="border-collapse:collapse;text-align:center">
    <tr>
    <td colspan="4" align="left">&ensp;&ensp;&ensp;&ensp;减免类型:${printData.funeralDead.exemptionType} </td>
    <td colspan="4" align="center">
    逝者编号：${printData.funeralDead.businessCode} </td>
    <tr>
    <tr>
      <td style="border: 1px solid black;width:60px;height:100px;" rowspan="2"
      >逝<br>者<br>信<br>息
      </td>
      <td style="border: 1px solid black;width:80px;height:50px;">姓名</td>
      <td style="border: 1px solid black;width:100px;height:50px" colspan="2">${printData.funeralDead.deadName}</td>
      <td style="border: 1px solid black;width:80px;height:50px">户籍地址</td>
      <td style="border: 1px solid black;width:100px;height:50px" colspan="2">
       ${printData.funeralDead.householdRegistrationPlace}</td>
    </tr>
    <tr>
      <td style="border: 1px solid black;width:80px;height:50px">年龄</td>
      <td style="border: 1px solid black;width:50px;height:50px">${printData.funeralDead.deadAge}</td>
      <td style="border: 1px solid black;width:50px;height:50px">性别</td>
      <td style="border: 1px solid black;width:80px;height:50px">${printData.funeralDead.deadGender}</td>
      <td style="border: 1px solid black;width:30px;height:50px">证件号码</td>
      <td style="border: 1px solid black;width:70px;height:50px">${printData.funeralDead.certificateNo}</td>
    </tr>
    <tr>
      <td style="border: 1px solid black;width:60px;height:220px" rowspan="2">
        减<br>免<br>项<br>目<br>及<br>金<br>额
      </td>
      <td style="border-right: 1px solid black;width:500px;height:220px" align="left" valign="top" colspan="6">
       ${trStr}
      </td>
    </tr>
    <tr>
      <td style="height: 50px" align="left" valign="bottom" colspan="2">
      减免合计: ${printData.abatementTotalCharge}</td>
      <td align="left" valign="bottom" colspan="2">大写金额: ${printData.abatementTotalChargeText}</td>
      <td style="border-right: 1px solid black;" colspan="2"></td>
    </tr>
    <tr>
      <td style="border: 1px solid black;height:190px" rowspan="3">丧<br>事<br>经<br>办<br>人</td>
      <td style="border: 1px solid black;width: 100px; height:40px">姓名</td>
      <td style="border: 1px solid black;" align="left" colspan="2">
        ${printData.familyAgent.agentName}</td>
      <td style="border: 1px solid black;width: 100px; height:40px">证件号码</td>
      <td style="border: 1px solid black;" align="left" colspan="2">
        ${printData.familyAgent.certificateNo}</td>
    </tr>
    <tr>
      <td style="border: 1px solid black;">与逝者关系</td>
      <td style="border: 1px solid black;height:40px" align="left" colspan="2">
        ${printData.familyAgent.agentRelation}</td>
      <td style="border: 1px solid black;">联系电话</td>
      <td style="border: 1px solid black;" align="left" colspan="2">
    ${printData.familyAgent.mobilePhone}</td>
    </tr>
    <tr>
      <td style="height:110px" align="left" valign="top" colspan="3"><br>签字:</td>
      <td style="border-right: 1px solid black;" align="right" valign="bottom" colspan="3">
      &ensp;&ensp;&ensp;&ensp;年&ensp;&ensp;&ensp;&ensp;月&ensp;&ensp;&ensp;&ensp;日&ensp;&ensp;<br>&ensp;
      </td>
    </tr>
    <tr>
      <td style="border: 1px solid black;height:160px" rowspan="3">殡<br>仪<br>馆<br>审<br>核<br>情<br>况</td>
      <td style="border-top: 1px solid #000000;border-right: 1px solid black;width: 100px"
          align="left" valign="top" colspan="3"><br>经办人:
      </td>
      <td style="border-right: 1px solid black;border-top: 1px solid black; width: 100px"
          align="left" valign="top" colspan="3"><br>审核意见:
      </td>
    </tr>
    <tr>
      <td style="border-right: 1px solid black;" align="left" colspan="3">
        &ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;${printData.fullName}
      </td>
      <td style="border-right: 1px solid black;" align="left" colspan="3">
        &ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;(公章)
      </td>
    </tr>
    <tr>
      <td style="border-right: 1px solid black;" align="right" valign="bottom" colspan="3">
      ${dateStr}&ensp;&ensp;
      </td>
      <td style="border-right: 1px solid black;" align="right" valign="bottom" colspan="3">
      &ensp;&ensp;&ensp;&ensp;年&ensp;&ensp;&ensp;&ensp;月&ensp;&ensp;&ensp;&ensp;日&ensp;&ensp;
      </td>
    </tr>
    <tr>
      <td style="border: 1px solid black;height:120px" colspan=>说<br>明</td>
      <td style="border: 1px solid black;" align="left" colspan="6">
        1.此表内容据实填写,弄虚作假,追回费用,并追究责。
        <br>2.未发生的免费项目不折现.不折抵。
        <br>3.此表一式三份，一份由殡仪馆存档备查，两份作为向财政部门申请资金的原始依据。
        <br>
      </td>
    </tr>
  </table>`;
      //设置字体
      LODOP.SET_PRINT_STYLE("FontSize", 8);
      //调用打印控件进行测试
      LODOP.ADD_PRINT_HTM(
        90,
        220,
        500,
        25,
        "<p style='font-size:30px;font-weight: bold;'>减免基本殡葬服务费用申请表</p>"
      );
      let time = `打印时间：${dataFormate(new Date())}`;
      //打印协议
      // LODOP.SET_PRINT_PAGESIZE(1,148,210,"");//设置纸张为80mm*60mm
      // LODOP.SET_PRINT_STYLEA(0,"AngleOfPageInside",90); //设置为横向
      // LODOP.SET_PRINT_PAGESIZE(2,100,50,0);
      LODOP.ADD_PRINT_BARCODE(40, 600, 100, 100, "QRCode", recOperationcode);
      LODOP.ADD_PRINT_HTM(130, 60, 1000, 1000, table);
      //LODOP.ADD_PRINT_HTM(20, 550, 1000, 300, time);
      LODOP.PREVIEW();
    },
    //
  },
  watch: {
    //监听值变化
    ruleItems() {
    },
    processStates() {
      let states = this.processStates;
    },
    DialogAddCarry() {
      if (this.DialogAddCarry == false) {
        this.searchData(this.businessCode);
      }
    },
    DialogColdStorage() {
      if (this.DialogColdStorage == false) {
        this.searchData(this.businessCode);
      }
    },
    DialogFace() {
      if (this.DialogFace == false) {
        this.searchData(this.businessCode);
      }
    },
    DialogWakeUp() {
      if (this.DialogWakeUp == false) {
        this.searchData(this.businessCode);
      }
    },
    DialogFareWell() {
      if (this.DialogFareWell == false) {
        this.searchData(this.businessCode);
      }
    },
    DialogFire() {
      if (this.DialogFire == false) {
        this.searchData(this.businessCode);
      }
    },
    DialogGoodsService() {
      if (this.DialogGoodsService == false) {
        this.searchData(this.businessCode);
      }
    },
  },
  computed: {
    //计算属性
    Charge() {
      let charge = {
        total: 0.0,
        Settled: 0.0,
        discountCharge: 0.0,
        benefitCharge: 0.0,
        realityCharge: 0.0,
        unSettled: 0.0,
        unDiscountCharge: 0.0,
        unBenefitCharge: 0.0,
        unrealityCharge: 0.0,
      };
      const arr = [
        "transportTasks",
        "coldStorageTasks",
        "faceLiftTasks",
        "wakeMournTasks",
        "farewellMournTasks",
        "cremationTasks",
        "funeralSuppliesTasks",
      ];
      const arr2 = ["faceLiftTasks", "funeralSuppliesTasks"];
      for (let i = 0; i < arr.length; i++) {
        if (this.ruleFormCalc[arr[i]] && this.ruleFormCalc[arr[i]].length > 0) {
          this.ruleFormCalc[arr[i]].forEach((item) => {
            //如果goodsServices是对象
            console.log(item);
            if (item && item.charges && item.charges.goodsServices) {
              item.charges.goodsServices.forEach((n) => {
                if (n.asSettled == 1) {
                  //已结算
                  if (n.itemCharge) {
                    charge.Settled += Number(n.itemCharge);
                  }
                  if (n.discountCharge) {
                    charge.discountCharge += Number(n.discountCharge);
                  }
                  if (n.benefitCharge) {
                    charge.benefitCharge += Number(n.benefitCharge);
                  }
                } else if (n.asSettled == 0) {
                  //未结算
                  if (n.itemCharge) {
                    charge.unSettled += Number(n.itemCharge);
                  }
                  if (n.discountCharge) {
                    charge.unDiscountCharge += Number(n.discountCharge);
                  }
                  if (n.benefitCharge) {
                    charge.unBenefitCharge += Number(n.benefitCharge);
                  }
                }
              });
            }
          });
        }
      }
      for (let i = 0; i < arr2.length; i++) {
        if (
          this.ruleFormCalc[arr2[i]] &&
          this.ruleFormCalc[arr2[i]].length > 0
        ) {
          this.ruleFormCalc[arr2[i]].forEach((n) => {
            //如果goodsServices是对象
            if (n.asSettled == 1) {
              //已结算
              if (n.itemCharge) {
                charge.Settled += Number(n.itemCharge);
              }
              if (n.discountCharge) {
                charge.discountCharge += Number(n.discountCharge);
              }
              if (n.benefitCharge) {
                charge.benefitCharge += Number(n.benefitCharge);
              }
            } else if (n.asSettled == 0) {
              //未结算
              if (n.itemCharge) {
                charge.unSettled += Number(n.itemCharge);
              }
              if (n.discountCharge) {
                charge.unDiscountCharge += Number(n.discountCharge);
              }
              if (n.benefitCharge) {
                charge.unBenefitCharge += Number(n.benefitCharge);
              }
            }
          });
        }
      }
      /*总费用合计*/
      charge.total = Number(charge.unSettled) + Number(charge.Settled);
      /*未结算*/
      charge.unrealityCharge =
        Number(charge.unSettled) -
        Number(charge.unDiscountCharge) -
        Number(charge.unBenefitCharge);
      /*已结算*/
      charge.realityCharge =
        Number(charge.Settled) -
        Number(charge.discountCharge) -
        Number(charge.benefitCharge);
      for (let i in charge) {
        charge[i] = toFixed(charge[i], 2);
      }
      return charge; //总计，已结算, 优惠减免,实收合计,  未结算:,优惠减免: 待付金额:
    },
  },
};
</script>
<style>
.Service .PageContent .el-select .el-input,
.Service .PageContent .el-select {
  width: 10vw;
  min-width: 120px;
}
</style>
<style scoped>
.Service {
  background: rgb(239, 239, 239);
}

.border1 {
  border: 1px solid rgb(235, 238, 245);
  padding: 30px;
  margin-bottom: 30px;
}

.edit-cell {
  padding: 3px;
}

.el-form-item {
  margin-bottom: 5px !important;
}

.w150 {
  display: inline-block;
  width: 150px;
}

.totalw {
  display: inline-block;
  width: 100px;
  font-weight: 600;
}

.PageContent {
  height: auto !important;
}

.totalmoney {
  background: rgb(255, 255, 255);
  padding-right: 50px;
  overflow: hidden;
  border-radius: 10px;
  padding-top: 30px;
  white-space: nowrap;
}
</style>
